@remodex/rmx 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,4 +68,4 @@ default_mode_request_user_input = true`})]}),(0,z.jsxs)(`div`,{className:`codex-
68
68
  }'`;return(0,z.jsxs)(`section`,{className:`panel api-panel awi-usage-panel`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:n(`api.workspace.usageExamples`)}),(0,z.jsxs)(`div`,{className:`awi-usage-panel-body`,children:[(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageChatTitle`)}),(0,z.jsx)(wf,{text:i})]}),(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageResponsesTitle`)}),(0,z.jsx)(wf,{text:a})]}),t&&(0,z.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,z.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageMessagesTitle`)}),(0,z.jsx)(wf,{text:o})]})]})]})}var Af=[`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`],jf={opencode:`api.clientConfig.clientOpencode`,pi:`api.clientConfig.clientPi`,omp:`api.clientConfig.clientOmp`,hermes:`api.clientConfig.clientHermes`,openclaw:`api.clientConfig.clientOpenclaw`,kimi:`api.clientConfig.clientKimi`,gajae:`api.clientConfig.clientGajae`},Mf={opencode:`/provider-icons/opencode.svg`,pi:`/provider-icons/pi.svg`};function Nf({client:e,apiBase:t,onOpenDetails:n,onCopy:r,onDownload:i}){let a=Q(),[o,s]=(0,_.useState)(0),c=[t,e,String(o)].join(`|`),[l,u]=(0,_.useState)(null);(0,_.useEffect)(()=>{let n=new AbortController,r=!1;return(async()=>{try{let i=await fetch(`${t}/api/client-config?client=${encodeURIComponent(e)}`,{signal:n.signal});if(!i.ok)throw Error(String(i.status));let a=await i.json();if(r)return;u({key:c,data:a,failed:!1})}catch{if(r)return;u({key:c,data:null,failed:!0})}})(),()=>{r=!0,n.abort()}},[t,e,c]);let d=l!==null&&l.key===c?l:null,f=d?.data??null,p=d?.failed??!1,m=d===null,h=a(jf[e]),g=Mf[e],v=f?.text??``,y=(0,_.useCallback)(t=>{f&&n(e,f,v,t.currentTarget)},[e,f,v,n]);return(0,z.jsxs)(`li`,{className:`awi-clientconfig-row`,children:[(0,z.jsx)(`span`,{className:`awi-clientconfig-mark`,"aria-hidden":`true`,children:g?(0,z.jsx)(`img`,{src:g,alt:``,width:20,height:20}):(0,z.jsx)(`span`,{className:`awi-clientconfig-monogram`,children:h.slice(0,1)})}),(0,z.jsxs)(`span`,{className:`awi-clientconfig-identity`,children:[(0,z.jsx)(`span`,{className:`awi-clientconfig-name`,children:h}),(0,z.jsx)(`span`,{className:`muted text-label awi-clientconfig-meta`,children:m?a(`api.clientConfig.loading`):p||!f?(0,z.jsx)(`span`,{role:`alert`,children:a(`api.clientConfig.rowError`,{client:h})}):a(`api.clientConfig.rowMeta`,{destination:f.destination,count:f.modelCount})})]}),(0,z.jsx)(`span`,{className:`awi-clientconfig-row-actions`,children:p&&!m?(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>s(e=>e+1),children:a(`common.retry`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":a(`api.clientConfig.copyAria`,{client:h}),disabled:!f,onClick:()=>{f&&r(e,v)},children:a(`api.clientConfig.copy`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,"aria-label":a(`api.clientConfig.downloadAria`,{client:h}),disabled:!f,onClick:()=>{f&&i(e,f,v)},children:a(`api.clientConfig.download`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":a(`api.clientConfig.detailsAria`,{client:h}),disabled:!f,onClick:y,children:a(`api.clientConfig.details`)})]})})]})}function Pf({client:e,envelope:t,json:n,hasKeys:r,onClose:i,onCopy:a,onDownload:o}){let s=Q(),c=(0,_.useRef)(null),l=`awi-clientconfig-dialog-${e}`;(0,_.useEffect)(()=>{let e=c.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]);let u=(0,_.useCallback)(e=>{e.preventDefault(),i()},[i]);return(0,z.jsxs)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":l,onCancel:u,children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":s(`common.close`),tabIndex:-1,onClick:i}),(0,z.jsxs)(`div`,{className:`modal-card awi-clientconfig-dialog`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:l,children:s(jf[e])}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:i,children:s(`common.close`)})]}),(0,z.jsx)(`pre`,{className:`api-code api-example-pre awi-clientconfig-json`,tabIndex:0,role:`group`,"aria-label":s(`api.clientConfig.jsonLabel`,{client:s(jf[e])}),children:n}),(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-count`,children:s(`api.clientConfig.modelCount`,{count:t.modelCount})}),t.modelsWithoutLimits>0&&(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-degraded`,children:s(`api.clientConfig.missingLimits`,{count:t.modelsWithoutLimits,total:t.modelCount})}),!r&&(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-nokey`,children:s(`api.clientConfig.noKeyYet`,{env:t.apiKeyEnv})}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:s(`api.clientConfig.destination`)}),(0,z.jsx)(wf,{text:t.destination})]}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:s(`api.clientConfig.envHint`)}),(0,z.jsx)(wf,{text:t.exportHint})]}),(0,z.jsx)(`p`,{className:`muted small awi-clientconfig-merge`,children:s(`api.clientConfig.mergeWarning`)}),(0,z.jsx)(`p`,{className:`muted text-label awi-clientconfig-where-title`,children:s(`api.clientConfig.whereDisclosure`)}),(0,z.jsx)(`p`,{className:`muted small`,children:s(`api.clientConfig.whereBody`)}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:a,children:s(`api.clientConfig.copy`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:o,children:s(`api.clientConfig.download`)})]})]})]})}function Ff({apiBase:e,baseUrl:t,hasKeys:n}){let r=Q(),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(``),c=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(i!==null)return;let e=c.current;e&&(c.current=null,e.isConnected&&e.focus())},[i]);let l=(0,_.useCallback)(async(e,t,n)=>{try{await navigator.clipboard.writeText(t),s(n?r(`api.clientConfig.copiedAnnounceClient`,{client:r(jf[e])}):r(`api.clientConfig.copiedAnnounce`))}catch{s(r(`api.clientConfig.copyFailed`))}},[r]),u=(0,_.useCallback)((e,t,n)=>{let i=URL.createObjectURL(new Blob([n],{type:t.mediaType})),a=document.createElement(`a`);a.href=i,a.download=t.filename,a.click(),URL.revokeObjectURL(i),s(r(`api.clientConfig.downloadedAnnounce`,{filename:t.filename,destination:t.destination}))},[r]),d=(0,_.useCallback)(()=>a(null),[]),f=(0,_.useCallback)((e,t,n,r)=>{c.current=r,a({client:e,envelope:t,json:n})},[]);return(0,z.jsxs)(`section`,{className:`panel api-panel awi-clientconfig-panel`,children:[(0,z.jsx)(`div`,{className:`api-panel-head awi-clientconfig-head`,children:(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`api.clientConfig.title`)})}),(0,z.jsx)(`ul`,{className:`awi-clientconfig-rows`,"aria-label":r(`api.clientConfig.rowsLabel`),children:Af.map(t=>(0,z.jsx)(Nf,{client:t,apiBase:e,onOpenDetails:f,onCopy:(e,t)=>{l(e,t,!0)},onDownload:u},t))}),(0,z.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,z.jsx)(`span`,{className:`muted text-label`,children:r(`api.baseUrl`)}),(0,z.jsx)(wf,{text:t})]}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:o}),i&&(0,z.jsx)(Pf,{client:i.client,envelope:i.envelope,json:i.json,hasKeys:n,onClose:d,onCopy:()=>{l(i.client,i.json,!1)},onDownload:()=>u(i.client,i.envelope,i.json)})]})}function If({keys:e,keysLoading:t,keysLoadFailed:n,attributionSince:r,localeTag:i,busy:a,onSelect:o}){let s=Q();return(0,z.jsxs)(`div`,{className:`panel api-panel awi-keylist-panel`,"aria-busy":t,children:[(0,z.jsx)(`div`,{className:`api-panel-head`,children:(0,z.jsx)(`h3`,{className:`panel-title`,children:t?s(`api.activeKeysLoading`):s(`api.activeKeys`,{count:e.length})})}),t?(0,z.jsx)(`div`,{className:`api-active-keys-skeleton`,role:`status`,"aria-label":s(`common.loading`)}):e.length===0?(0,z.jsx)(`p`,{className:`muted small`,children:s(n?`api.keysLoadFailed`:`api.noKeys`)}):(0,z.jsx)(`div`,{className:`tbl-wrap`,children:(0,z.jsxs)(`table`,{className:`tbl awi-keylist-table`,children:[(0,z.jsx)(`thead`,{children:(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`th`,{children:s(`api.colName`)}),(0,z.jsx)(`th`,{children:s(`api.colKey`)}),(0,z.jsx)(`th`,{children:s(`api.attribution.requests7d`)}),(0,z.jsx)(`th`,{children:s(`api.attribution.lastUsed`)})]})}),(0,z.jsx)(`tbody`,{children:e.map(e=>(0,z.jsxs)(`tr`,{children:[(0,z.jsx)(`td`,{children:(0,z.jsx)(`button`,{type:`button`,className:`awi-keylist-name`,disabled:a,onClick:()=>o(e.id),children:e.name})}),(0,z.jsx)(`td`,{children:(0,z.jsx)(`code`,{children:e.prefix})}),(0,z.jsx)(`td`,{children:r?e.usage.ambiguous?s(`api.attribution.railAmbiguous`):e.usage.requests7d.toLocaleString(i):s(`api.attribution.unavailable`)}),(0,z.jsx)(`td`,{children:!r||e.usage.ambiguous?`—`:e.usage.lastUsedAt?xf(e.usage.lastUsedAt,i):s(`api.attribution.neverUsed`)})]},e.id))})]})})]})}function Lf({keys:e,apiBase:t,attributionSince:n,historyTruncated:r,authMatrix:i,keysLoading:a,keysLoadFailed:o,endpoints:s,claudeCodeEnabled:c,localeTag:l,newName:u,creating:d,newKey:f,copied:p,filteredModels:m,modelsLoading:h,modelsRefreshing:g=!1,modelsLoadFailed:v,modelCount:y,hasModelData:b,modelQuery:x,copiedModelId:S,modelTests:C,canTestModels:w,onNewNameChange:T,onCreate:E,onDismissNewKey:D,onCopyKey:O,onDelete:k,onRename:A,onModelQueryChange:j,onCopyModelId:M,onTestModel:N,onRetryModels:P,sourceLabel:F,protocolLabel:I}){let L=Q(),[R,B]=(0,_.useState)(null),[V,H]=(0,_.useState)(!1),[U,W]=(0,_.useState)(!1),[G,ee]=(0,_.useState)(!1),[te,K]=(0,_.useState)(!1),[q,J]=(0,_.useState)(``),[Y,ne]=(0,_.useState)(!1),[X,re]=(0,_.useState)(!1),[ie,oe]=(0,_.useState)(!1),se=R?e.find(e=>e.id===R)??null:null,ce=G||Y,le=(0,_.useMemo)(()=>[{id:`keys`,label:L(`api.section.keys`),meta:a?void 0:String(e.length)},{id:`connect`,label:L(`api.section.connect`)},{id:`endpoints`,label:L(`api.section.endpoints`)},{id:`models`,label:L(`api.section.models`),meta:String(y)},{id:`examples`,label:L(`api.section.examples`)}],[L,e.length,a,y]),ue=()=>{H(!1),W(!1)},de=()=>{B(null),ue(),K(!1),re(!1),oe(!1)};(0,_.useEffect)(()=>{if(!V)return;let e=window.setTimeout(()=>W(!0),300);return()=>window.clearTimeout(e)},[V]);let pe=()=>{se&&H(!0)},me=async()=>{if(!(!se||!U||G)){ee(!0),oe(!1);try{await k(se.id)?(ue(),B(null)):oe(!0)}finally{ee(!1)}}},he=()=>{se&&(J(se.name),re(!1),K(!0))},ge=async()=>{if(!se||Y)return;let e=q.trim();if(!e||e===se.name){K(!1);return}ne(!0),re(!1);try{await A(se.id,e)?K(!1):re(!0)}finally{ne(!1)}};return(0,z.jsxs)(`div`,{className:`apikeys-workspace-shell`,children:[!se&&(0,z.jsx)(zl,{scope:`api`,items:le,ariaLabel:L(`api.workspace.sections`)}),(0,z.jsx)(`div`,{className:`apikeys-workspace-root`,children:(0,z.jsx)(`section`,{className:`apikeys-workspace-main`,"aria-label":L(`api.workspace.details`),children:se?(0,z.jsxs)(`div`,{className:`awi-detail`,children:[(0,z.jsx)(`div`,{className:`awi-detail-toolbar`,children:(0,z.jsxs)(`button`,{type:`button`,className:`awi-back`,onClick:de,disabled:ce,children:[(0,z.jsx)(fe,{className:`awi-back-chevron`,"aria-hidden":`true`}),L(`modal.back`)]})}),(0,z.jsxs)(`div`,{className:`awi-detail-body`,children:[(0,z.jsxs)(`div`,{className:`awi-detail-head`,children:[(0,z.jsx)(`h2`,{className:`awi-detail-title`,children:se.name}),(0,z.jsx)(`span`,{className:`awi-detail-actions`,children:V?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm awi-confirm-delete`,onClick:()=>{me()},disabled:!U||G,children:[(0,z.jsx)(ae,{}),` `,L(G?`api.key.deleting`:`api.confirm`)]},`confirm-delete`),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:ue,disabled:G,children:L(`common.cancel`)})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:he,disabled:te,children:L(`api.key.rename`)},`rename`),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:pe,"aria-label":L(`api.deleteAria`),children:[(0,z.jsx)(ae,{}),` `,L(`api.workspace.deleteKey`)]},`request-delete`)]})})]}),V&&(0,z.jsx)(`p`,{className:`muted awi-delete-hint`,children:L(`api.workspace.deleteConfirm`)}),ie&&(0,z.jsx)(`p`,{className:`awi-delete-error`,role:`alert`,children:L(`api.deleteFailed`)}),te&&(0,z.jsxs)(`div`,{className:`awi-rename`,children:[(0,z.jsx)(`label`,{className:`awi-rename-label`,htmlFor:`awi-key-name`,children:L(`api.key.name`)}),(0,z.jsx)(`input`,{id:`awi-key-name`,className:`input`,type:`text`,value:q,maxLength:64,disabled:Y,onChange:e=>J(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ge())}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>{ge()},disabled:Y,children:L(Y?`api.key.renaming`:`api.key.saveName`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>K(!1),disabled:Y,children:L(`common.cancel`)}),X&&(0,z.jsx)(`p`,{className:`awi-rename-error`,role:`alert`,children:L(`api.key.renameFailed`)})]}),(0,z.jsxs)(`div`,{className:`awi-section`,children:[(0,z.jsx)(`h3`,{className:`awi-section-title`,children:L(`api.workspace.keyDetails`)}),(0,z.jsxs)(`dl`,{className:`awi-kv`,children:[(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.workspace.keyPrefix`)}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(`code`,{children:se.prefix})})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.colCreated`)}),(0,z.jsx)(`dd`,{children:xf(se.createdAt,l)})]})]})]}),(0,z.jsxs)(`div`,{className:`awi-section`,children:[(0,z.jsx)(`h3`,{className:`awi-section-title`,children:L(`api.attribution.title`)}),n?se.usage.ambiguous?(0,z.jsx)(`p`,{className:`muted`,children:L(`api.attribution.ambiguous`)}):(0,z.jsxs)(`dl`,{className:`awi-kv`,children:[(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.attribution.requests7d`)}),(0,z.jsx)(`dd`,{children:se.usage.requests7d.toLocaleString(l)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(r?`api.attribution.totalRequestsAvailable`:`api.attribution.totalRequests`)}),(0,z.jsx)(`dd`,{children:se.usage.totalRequests.toLocaleString(l)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(`api.attribution.lastUsed`)}),(0,z.jsx)(`dd`,{children:se.usage.lastUsedAt?xf(se.usage.lastUsedAt,l):L(`api.attribution.neverUsed`)})]}),(0,z.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,z.jsx)(`dt`,{children:L(r?`api.attribution.sinceAvailable`:`api.attribution.since`)}),(0,z.jsx)(`dd`,{children:xf(n,l)})]})]}):(0,z.jsx)(`p`,{className:`muted`,children:L(`api.attribution.unavailableDetail`)})]})]})]}):(0,z.jsx)(`div`,{className:`awi-overview`,children:(0,z.jsxs)(`div`,{className:`awi-overview-section`,children:[(0,z.jsxs)(`div`,{id:Il(`api`,`keys`),className:`awi-section-anchor`,children:[(0,z.jsx)(Df,{keys:e,keysLoading:a,keysLoadFailed:o,newName:u,creating:d,newKey:f,copied:p,confirmDelete:null,localeTag:l,showKeyList:!1,onNewNameChange:T,onCreate:E,onDismissNewKey:D,onCopyKey:O,onConfirmDelete:()=>{},onCancelDelete:()=>{},onDelete:()=>{}}),(0,z.jsx)(If,{keys:e,keysLoading:a,keysLoadFailed:o,attributionSince:n,localeTag:l,busy:ce,onSelect:e=>{B(e),ue(),K(!1),re(!1),oe(!1)}})]}),(0,z.jsx)(`div`,{id:Il(`api`,`connect`),className:`awi-section-anchor`,children:(0,z.jsx)(Ff,{apiBase:t,baseUrl:s.baseUrl,hasKeys:e.length>0})}),(0,z.jsx)(`div`,{id:Il(`api`,`endpoints`),className:`awi-section-anchor`,children:(0,z.jsx)(Ef,{endpoints:s,claudeCodeEnabled:c,authMatrix:i})}),(0,z.jsx)(`div`,{id:Il(`api`,`models`),className:`awi-section-anchor`,children:(0,z.jsx)(Of,{filteredModels:m,modelsLoading:h,modelsRefreshing:g,modelsLoadFailed:v,modelCount:y,hasModelData:b,modelQuery:x,copiedModelId:S,modelTests:C,claudeCodeEnabled:c,onModelQueryChange:j,onCopyModelId:M,onTestModel:N,onRetryModels:P,canTestModels:w,sourceLabel:F,protocolLabel:I})}),(0,z.jsx)(`div`,{id:Il(`api`,`examples`),className:`awi-section-anchor`,children:(0,z.jsx)(kf,{endpoints:s,claudeCodeEnabled:c})})]})})})})]})}var Rf=[],zf=15e3;function Bf(e){let t=e.replace(/\/$/,``);if(!t)return yf;try{return new URL(t).host?bf(`${t}/v1/responses`):yf}catch{return yf}}function Vf(e){return!e||!vf(e.authMatrix)||!Array.isArray(e.keys)||e.keys.some(e=>!e||!gf(e.usage))?null:e}function Hf({apiBase:e,active:t=!0}){let{t:n,locale:r}=Z(),i=je.find(e=>e.code===r)?.htmlLang,a=`ocx.apikeys.list.v2:${e}`,o=`ocx.apikeys.models.v1:${e}`,s=`api-keys:${e}`,c=`api-models:${e}`,l=Vf(En(a)),u=En(o),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)({}),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),O=(0,_.useRef)(!1),k=(0,_.useCallback)(async t=>{let r=await lt(await fetch(`${e}/api/keys`,{signal:t}));if(!r||!vf(r.authMatrix))throw Error(n(`api.keysLoadFailed`));let i=r.keys??[];if(i.some(e=>!gf(e.usage)))throw Error(n(`api.keysLoadFailed`));let o=i,s=bf(r.endpoint??``),c={keys:o,endpoints:{baseUrl:r.baseUrl??s.baseUrl,responses:r.responsesEndpoint??r.endpoint??yf.responses,chatCompletions:r.chatCompletionsEndpoint??s.chatCompletions,messages:r.messagesEndpoint??s.messages,models:r.modelsEndpoint??s.models},claudeCodeEnabled:r.claudeCodeEnabled!==!1,...r.attributionSince?{attributionSince:r.attributionSince}:{},...r.historyTruncated===!0?{historyTruncated:!0}:{},authMatrix:r.authMatrix};return Dn(a,c),c},[e,a,n]),A=(0,_.useCallback)(async t=>{let r=await fetch(`${e}/v1/models`,{signal:t});if(!r.ok)throw Error(n(`api.modelsLoadFailed`));let i=await r.json(),a=Array.isArray(i)?i:typeof i==`object`&&i&&Array.isArray(i.data)?i.data:null;if(!a)throw Error(n(`api.modelsLoadFailed`));let s=a.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`).map(e=>mf(e)).sort((e,t)=>hf(e).localeCompare(hf(t)));return Dn(o,s),s},[e,o,n]),j=bs(s,[e],k,{isEmpty:e=>e.keys.length===0,initialData:l??void 0,enabled:t}),M=bs(c,[e],A,{isEmpty:e=>e.length===0,initialData:u??void 0,enabled:t}),N=j.state,P=M.state,F=N.data??l,I=P.data??u??Rf,L=F?.keys??[],R=F?.endpoints??Bf(e),B=F?.claudeCodeEnabled??!0,V=F?.attributionSince,H=F?.historyTruncated===!0,U=F?.authMatrix??[],W=j.refresh,G=M.refresh,ee=(0,_.useMemo)(()=>{let e=p.trim().toLowerCase();return e?I.filter(t=>hf(t).toLowerCase().includes(e)||t.displayName.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):I},[p,I]),te=async t=>{if(O.current)return!1;O.current=!0,C(!0),f(null);try{let r=t??b,i=await ct(await fetch(`${e}/api/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:r||`default`})}),n(`api.createFailed`));return typeof i?.key!=`string`||i.key.length===0?(f(n(`api.createFailed`)),!1):(T(i.key),x(``),W(),!0)}catch{return f(n(`api.createFailed`)),!1}finally{O.current=!1,C(!1)}},K=async t=>{f(null);let n=en(zf);try{return(await fetch(`${e}/api/keys`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t}),signal:n.signal})).ok?(W(),!0):!1}catch{return!1}finally{n.clear()}},q=async(t,n)=>{f(null);let r=en(zf);try{return(await fetch(`${e}/api/keys`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t,name:n}),signal:r.signal})).ok?(W(),!0):!1}catch{return!1}finally{r.clear()}},J=async()=>{if(w){f(null);try{await navigator.clipboard.writeText(w),D(!0),window.setTimeout(()=>D(!1),2e3)}catch{D(!1),f(n(`api.key.copyFailed`))}}},Y=async e=>{try{await navigator.clipboard.writeText(e),g(e),window.setTimeout(()=>g(t=>t===e?null:t),2e3)}catch{}},ne=e=>e.native?n(`api.sourceNative`):e.provider===`combo`?n(`api.sourceCombo`):e.custom?n(`api.sourceCustom`):Ut(e.provider,n),X=e=>n(e===`responses`?`api.protocolResponses`:e===`messages`?`api.protocolMessages`:`api.protocolChatCompletions`),re=(e,t)=>e===`responses`?{url:R.responses,body:{model:t,input:`ping`,max_output_tokens:1,stream:!1}}:e===`messages`?{url:R.messages,body:{model:t,max_tokens:1,messages:[{role:`user`,content:`ping`}]}}:{url:R.chatCompletions,body:{model:t,messages:[{role:`user`,content:`ping`}],max_tokens:1,stream:!1}},ie=(e,t,n)=>y(r=>({...r,[e]:{...r[e],[t]:n}})),ae=async(e,t)=>{if(!w)return;let r=hf(e),i=re(t,r);ie(r,t,{state:`testing`});try{let e=await fetch(i.url,{method:`POST`,headers:{"Content-Type":`application/json`,"x-opencodex-api-key":w},body:JSON.stringify(i.body)});if(!e.ok){let n=await e.text();ie(r,t,{state:`error`,detail:n.slice(0,160)||String(e.status)});return}ie(r,t,{state:`ok`})}catch(e){ie(r,t,{state:`error`,detail:e instanceof Error?e.message:n(`api.testFailed`)})}},oe=n(`api.subtitle`).split(`{authHeader}`);return(0,z.jsxs)(`section`,{className:`api-page`,"aria-busy":N.refreshing||P.refreshing||void 0,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:n(`api.title`)})}),(0,z.jsxs)(`p`,{className:`page-sub`,children:[oe[0],(0,z.jsx)(`code`,{children:`x-opencodex-api-key`}),oe[1]]}),d&&(0,z.jsx)($,{tone:`err`,children:d}),N.showError&&F&&(0,z.jsx)($,{tone:`err`,children:n(`api.keysLoadFailed`)}),N.showSkeleton&&!F?(0,z.jsx)(Ss,{label:n(`api.activeKeysLoading`),rows:4}):N.kind===`failed-cold`&&!F?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)($,{tone:`err`,children:N.error instanceof Error?N.error.message:n(`api.keysLoadFailed`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>W(),children:n(`common.retry`)})]}):(0,z.jsx)(z.Fragment,{children:(0,z.jsx)(Lf,{keys:L,apiBase:e,attributionSince:V,historyTruncated:H,authMatrix:U,keysLoading:!1,keysLoadFailed:N.showError,endpoints:R,claudeCodeEnabled:B,localeTag:i,newName:b,creating:S,newKey:w,copied:E,filteredModels:ee,modelsLoading:P.showSkeleton&&!P.data&&!u,modelsRefreshing:P.refreshing&&P.showError&&(P.data!==void 0||u!==null),modelsLoadFailed:P.showError,modelCount:I.length,hasModelData:P.data!==void 0||u!==null,modelQuery:p,copiedModelId:h,modelTests:v,onNewNameChange:x,onCreate:()=>{te()},onDismissNewKey:()=>T(null),onCopyKey:()=>{J()},onDelete:K,onRename:q,onModelQueryChange:m,onCopyModelId:e=>{Y(e)},onTestModel:(e,t)=>{ae(e,t)},onRetryModels:()=>{G({forceLoading:!0})},canTestModels:w!==null,sourceLabel:ne,protocolLabel:X})})]})}function Uf(e,t){let n=(e??[]).map(e=>({value:e,label:vs(e)}));return[{value:``,label:t},...n]}function Wf(e){let t=e.autoConnectSupported===!0;return{autoConnectSupported:t,systemEnv:t&&e.systemEnv===!0}}var Gf=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`];function Kf(e){let t=`http://127.0.0.1:${e.port}`,n=e.authMode===`auto`?e.markerMode??`subscription`:e.authMode,r=e.autoContext&&e.maxContextTokens===null,i=Gf.filter(t=>e.effectiveModelEnv[t]).map(t=>`export ${t}=${e.effectiveModelEnv[t]}`);return[`export ANTHROPIC_BASE_URL=${t}`,...n===`proxy`?[`export ANTHROPIC_AUTH_TOKEN=opencodex-proxy`]:[`# no ANTHROPIC_AUTH_TOKEN: your claude.ai login (and connectors) stay active`],`export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1`,...n===`proxy`?['[ -z "${CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST+x}" ] && export CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1']:[],...r?[`export CLAUDE_CODE_AUTO_COMPACT_WINDOW=${e.autoCompactWindow??35e4}`]:[],...i,`claude`].join(`
69
69
  `)}function qf(e){return e?e.backend??`auto`:`inherit`}function Jf(e,t){if(t!==`inherit`)return t===`auto`?{...e,backend:void 0}:{...e,backend:t}}function Yf(e,t){return{...e,model:t}}function Xf(e){if(!e)return null;let t=(e.model??``).trim();return e.backend?{backend:e.backend,model:t}:t?{backend:null,model:t}:null}function Zf({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,z.jsxs)(`label`,{className:`toggle`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,z.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function Qf({supported:e,checked:t,onChange:n}){let r=Q(),i=e?void 0:`claude-system-env-unsupported`;return(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:r(`claude.systemEnv`)}),e?(0,z.jsx)(`span`,{className:`desc`,children:r(`claude.systemEnvDesc`)}):(0,z.jsx)(`span`,{className:`desc`,id:i,children:(0,z.jsx)(Be,{k:`claude.systemEnvUnsupported`,cmd:`rmx claude`})}),e&&t&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:r(`claude.systemEnvWarn`)})]}),(0,z.jsx)(Zf,{label:r(`claude.systemEnv`),checked:e&&t,disabled:!e,describedBy:i,onChange:n})]})}function $f({value:e,tierHaikuModel:t,options:n,onChange:r}){let i=Q(),a=t??e;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:i(`claude.smallFastModelAccurateHint`)}),(0,z.jsx)(rt,{value:e,options:n,onChange:r,label:i(`claude.smallFastModel`),style:{maxWidth:420}}),a===``&&(0,z.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:i(`claude.smallFastModelNativeWarning`)})]})}function ep(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)try{return crypto.randomUUID()}catch{}let e=new Uint8Array(16);if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`)crypto.getRandomValues(e);else for(let t=0;t<16;t++)e[t]=Math.floor(Math.random()*256);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function tp(e,t=`en`){if(e>=1e6){let n=e/1e6,r=n.toFixed(1).replace(/\.0$/,``);return Number.isInteger(n)||Number(r)*1e6===e?new Intl.NumberFormat(t,{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:+!Number.isInteger(n)}).format(e):`${Math.round(e/1e3)}k`}return`${Math.round(e/1e3)}k`}function np(e,t){return e&&[`claude-json-oauth`,`claude-credentials-file`,`macos-keychain`,`exported-env`].includes(e)?t(`claude.authSource.${e}`):t(`claude.authSource.unknown`)}function rp({state:e,autoCompactOptions:t,availableModels:n,onStateChange:r}){let i=Q();return(0,z.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.authMode`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.authModeHint`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(rt,{value:e.authMode,options:[{value:`auto`,label:i(`claude.authModeAuto`)},{value:`subscription`,label:i(`claude.authModeSubscription`)},{value:`proxy`,label:i(`claude.authModeProxy`)}],onChange:t=>r({...e,authMode:t}),label:i(`claude.authMode`),style:{minWidth:220},align:`right`,portal:!0})})]}),e.authModeOrigin&&(0,z.jsxs)(`div`,{className:`claude-effective-auth${e.authModeOrigin===`auto-unknown`?` warn`:``}`,role:`status`,children:[(0,z.jsx)(`span`,{className:`claude-effective-auth-label`,children:i(`claude.effectiveMode.label`)}),(0,z.jsxs)(`span`,{children:[e.authModeOrigin===`manual`?i(`claude.effectiveMode.manual`,{mode:e.markerMode===`proxy`?i(`claude.authModeProxy`):i(`claude.authModeSubscription`)}):e.authModeOrigin===`auto-present`?i(`claude.effectiveMode.autoPresent`,{source:np(e.authFoundBy,i)}):e.authModeOrigin===`auto-absent`?i(`claude.effectiveMode.autoAbsent`):i(`claude.effectiveMode.autoUnknown`),e.admissionKeyActive===!0?` ${i(`claude.effectiveMode.admissionKey`)}`:``]})]}),(0,z.jsx)(Qf,{supported:e.autoConnectSupported,checked:e.systemEnv,onChange:t=>r({...e,systemEnv:t})}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.fastMode`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.fastModeDesc`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(rt,{value:e.fastMode===null?`auto`:e.fastMode?`on`:`off`,options:[{value:`auto`,label:i(`claude.fastAuto`)},{value:`on`,label:i(`claude.fastOn`)},{value:`off`,label:i(`claude.fastOff`)}],onChange:t=>r({...e,fastMode:t===`auto`?null:t===`on`}),label:i(`claude.fastMode`),style:{minWidth:140},align:`right`,portal:!0})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.autoContext`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.autoContextDesc`)}),e.maxContextTokens!==null&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:i(`claude.autoContextInert`)})]}),(0,z.jsx)(Zf,{label:i(`claude.autoContext`),checked:e.autoContext,onChange:t=>r({...e,autoContext:t})})]}),e.autoContext&&(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.autoCompactWindow`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.autoCompactWindowDesc`)}),e.autoCompactWindow!==null&&(0,z.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:i(`claude.autoCompactWindowWarn`)})]}),(0,z.jsx)(`div`,{className:`setting-controls`,children:(0,z.jsx)(rt,{value:e.autoCompactWindow===null?``:String(e.autoCompactWindow),options:t,onChange:t=>r({...e,autoCompactWindow:t===``?null:Number(t)}),label:i(`claude.autoCompactWindow`),style:{minWidth:130},align:`right`,portal:!0})})]}),(0,z.jsxs)(`div`,{className:`setting-row`,children:[(0,z.jsxs)(`div`,{className:`setting-label`,children:[(0,z.jsx)(`span`,{className:`title`,children:i(`claude.injectAgents`)}),(0,z.jsx)(`span`,{className:`desc`,children:i(`claude.injectAgentsDesc`)})]}),(0,z.jsx)(Zf,{label:i(`claude.injectAgents`),checked:e.injectAgents,onChange:t=>r({...e,injectAgents:t})})]}),[`webSearchSidecar`,`visionSidecar`].map(t=>{let a=e[t],o=t===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,s=t===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`,c=`claude-sidecar-models-${t}`;return(0,z.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,z.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,z.jsx)(`span`,{className:`title`,children:i(o)}),(0,z.jsx)(`span`,{className:`desc`,children:i(s)})]}),(0,z.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,z.jsx)(rt,{value:qf(a),options:[{value:`inherit`,label:i(`claude.useMainSetting`)},{value:`auto`,label:i(`dash.backendAuto`)},{value:`openai`,label:i(`dash.backendOpenAI`)},{value:`anthropic`,label:i(`dash.backendAnthropic`)}],onChange:n=>{r({...e,[t]:Jf(a,n)})},label:i(`dash.sidecarBackend`),portal:!0}),(0,z.jsx)(`input`,{className:`input mono`,value:a?.model??``,onChange:n=>{r({...e,[t]:Yf(a,n.target.value)})},placeholder:i(`claude.sidecarModelPlaceholder`),disabled:!a,list:a?c:void 0,"aria-label":i(`dash.sidecarModel`),style:{minWidth:210},autoComplete:`off`}),a&&(0,z.jsx)(`datalist`,{id:c,children:n.map(e=>(0,z.jsx)(`option`,{value:e},e))})]})]},t)})]})}function ip({manualEnv:e}){let t=Q();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,z.jsx)(Be,{k:`claude.quickstartHint`,cmd:`rmx claude`})}),(0,z.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`rmx claude`}),(0,z.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,z.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:t(`claude.manualEnv`)}),(0,z.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:e})]})]})}function ap({rows:e,onRowsChange:t}){let n=Q();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:n(`claude.modelMapHint`)}),(0,z.jsx)(`div`,{className:`stack`,style:{gap:8},children:e.map((r,i)=>(0,z.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,z.jsx)(`input`,{className:`input mono`,value:r.from,placeholder:n(`claude.mapFrom`),"aria-label":n(`claude.mapFrom`),onChange:n=>t(e.map((e,t)=>t===i?{...e,from:n.target.value}:e)),style:{flex:1}}),(0,z.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,z.jsx)(`input`,{className:`input mono`,value:r.to,placeholder:n(`claude.mapTo`),"aria-label":n(`claude.mapTo`),onChange:n=>t(e.map((e,t)=>t===i?{...e,to:n.target.value}:e)),style:{flex:1}}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>t(e.filter((e,t)=>t!==i)),"aria-label":n(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,z.jsx)(Y,{})})]},r.id))}),(0,z.jsx)(`div`,{style:{marginTop:8},children:(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>t([...e,{id:ep(),from:``,to:``}]),children:[(0,z.jsx)(ne,{}),` `,n(`claude.addMapping`)]})})]})}var op=`etc`;function sp(e){let t=new Map;for(let n of e){let e=/\(([^)]+)\)\s*$/.exec(n.display_name),r=e?e[1]:op,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t)}function cp({aliases:e}){let t=Q();return(0,z.jsxs)(`div`,{className:`claude-aliases`,children:[(0,z.jsx)(`p`,{className:`muted text-label claude-aliases-hint`,children:t(`claude.aliasesHint`)}),e.length===0?(0,z.jsx)(`div`,{className:`muted text-label`,children:t(`claude.none`)}):(0,z.jsx)(`div`,{className:`claude-aliases-scroll`,children:sp(e).map(([e,n])=>(0,z.jsxs)(`div`,{className:`claude-aliases-group`,children:[(0,z.jsxs)(`div`,{className:`claude-aliases-group-label`,children:[e===op?t(`claude.aliasProviderOther`):e,(0,z.jsx)(`span`,{className:`claude-aliases-group-count`,children:n.length})]}),(0,z.jsx)(`div`,{className:`claude-aliases-chips`,children:n.map(e=>(0,z.jsxs)(`span`,{className:`claude-aliases-chip`,children:[(0,z.jsx)(`code`,{className:`claude-aliases-chip-id`,children:e.id}),e.display_name?(0,z.jsx)(`span`,{className:`claude-aliases-chip-name`,children:e.display_name}):null]},e.id))})]},e))})]})}function lp({apiBase:e,active:t=!0}){let n=Q(),{locale:r}=Z(),i=je.find(e=>e.code===r)?.htmlLang??`en`,a=`ocx.claude-code.v1:${e}`,o=`claude-code:${e}`,s=(0,_.useMemo)(()=>En(a),[a]),[c,l]=(0,_.useState)(()=>s?.state??null),[u,d]=(0,_.useState)(()=>s?.rows??[]),[f,p]=(0,_.useState)(!!s),[m,h]=(0,_.useState)(``),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(`settings`),[x,S]=(0,_.useState)(!1),C=(0,_.useRef)(!1),w=(0,_.useCallback)(async t=>{let r=await ct(await fetch(`${e}/api/claude-code`,{signal:t}),n(`claude.loadFail`));if(!r)throw Error(n(`claude.loadFail`));let i={...r,authMode:r.authMode===`proxy`||r.authMode===`subscription`?r.authMode:`auto`,...Wf(r),fastMode:r.fastMode??null,maxContextTokens:r.maxContextTokens??null,autoContext:r.autoContext!==!1,autoCompactWindow:r.autoCompactWindow??null,injectAgents:r.injectAgents!==!1,effectiveModelEnv:r.effectiveModelEnv??{}},o=Object.entries(r.modelMap??{}).map(([e,t])=>({id:ep(),from:e,to:String(t)})),s={state:i,rows:o};if(t.aborted)throw Error(`Claude Code request aborted`);return l(i),d(o),p(!0),Dn(a,s),s},[e,a,n]),T=bs(o,[e],w,{isEmpty:()=>!1,enabled:t,initialData:s??void 0}),E=T.state,D=E.data??s,O=c??D?.state??null,k=f?u:D?.rows??u,A=(0,_.useMemo)(()=>Uf(O?.available,n(`claude.smallFastModelUnsetOption`)),[O?.available,n]),j=(0,_.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,9e5,1e6],t=O?.autoCompactWindow??null,r=t!==null&&!e.includes(t)?[...e,t].sort((e,t)=>e-t):e;return[{value:``,label:n(`claude.autoCompactDefault`)},...r.map(e=>({value:String(e),label:tp(e,i)}))]},[O?.autoCompactWindow,n,i]),M=async()=>{if(!O||C.current)return;C.current=!0,S(!0),h(``);let t=!O.enabled;try{await ct(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})}),n(`claude.saveFailed`)),l({...O,enabled:t}),T.refresh()}catch(e){v(!1),h(e instanceof Error&&e.message?e.message:n(`claude.networkError`))}finally{C.current=!1,S(!1)}},N=async()=>{if(!O)return;h(``);let t={};for(let e of k)e.from.trim()&&e.to.trim()&&(t[e.from.trim()]=e.to.trim());try{await ct(await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:O.enabled,authMode:O.authMode,systemEnv:O.systemEnv,fastMode:O.fastMode,autoContext:O.autoContext,autoCompactWindow:O.autoCompactWindow,injectAgents:O.injectAgents,smallFastModel:O.smallFastModel,modelMap:t,webSearchSidecar:Xf(O.webSearchSidecar),visionSidecar:Xf(O.visionSidecar)})}),n(`claude.saveFailed`)),v(!0),h(n(`claude.saved`)),T.refresh()}catch(e){v(!1),h(e instanceof Error&&e.message?e.message:n(`claude.networkError`))}};if(E.kind===`disabled`&&!D)return null;if(E.showSkeleton&&!D)return(0,z.jsx)(Ss,{label:n(`claude.loading`),rows:3});if(E.kind===`failed-cold`){let e=E.error instanceof Error?E.error.message:n(`claude.loadFail`);return(0,z.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[(0,z.jsx)($,{tone:`err`,children:e}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>T.refresh(),children:n(`common.retry`)})]})}if(!O)return null;let P=[{id:`settings`,label:n(`claude.workspace.settings`),body:(0,z.jsx)(rp,{state:O,autoCompactOptions:j,availableModels:O.available??[],onStateChange:l})},{id:`quickstart`,label:n(`claude.quickstart`),body:(0,z.jsx)(ip,{manualEnv:Kf(O)})},{id:`smallFast`,label:n(`claude.smallFastModel`),body:(0,z.jsx)($f,{value:O.smallFastModel,tierHaikuModel:O.tierModels?.haiku,options:A,onChange:e=>l({...O,smallFastModel:e})})},{id:`modelMap`,label:n(`claude.modelMap`),meta:String(k.length),body:(0,z.jsx)(ap,{rows:k,onRowsChange:e=>{p(!0),d(e)}})},{id:`aliases`,label:n(`claude.aliases`),meta:String(O.aliases.length),body:(0,z.jsx)(cp,{aliases:O.aliases})}],F=P.find(e=>e.id===y)??P[0],I=y===`settings`||y===`smallFast`||y===`modelMap`;return(0,z.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[m&&(0,z.jsx)($,{tone:g?`ok`:`err`,children:m}),E.showError&&(0,z.jsx)($,{tone:`err`,children:n(`claude.loadFail`)}),O&&(0,z.jsxs)(`div`,{className:`claudecode-connection-head`,children:[(0,z.jsx)(`span`,{id:`claudecode-connection-label`,children:n(`claude.enabledLabel`)}),(0,z.jsx)(tt,{on:O.enabled,onClick:()=>void M(),disabled:x,label:n(`claude.toggleAria`)})]}),(0,z.jsxs)(`div`,{className:`claudecode-workspace-root`,children:[(0,z.jsx)(`aside`,{className:`claudecode-workspace-rail`,"aria-label":n(`claude.pageTitle`),children:(0,z.jsx)(`div`,{className:`claudecode-workspace-rail-list`,children:P.map(e=>(0,z.jsx)(`button`,{type:`button`,className:`claudecode-workspace-rail-row${y===e.id?` claudecode-workspace-rail-row--selected`:``}`,onClick:()=>b(e.id),"aria-current":y===e.id?`true`:void 0,children:(0,z.jsx)(`span`,{className:`claudecode-workspace-rail-name`,children:e.label})},e.id))})}),(0,z.jsxs)(`section`,{className:`claudecode-workspace-main`,"aria-label":F.label,children:[(0,z.jsxs)(`div`,{className:`ccw-main-head`,children:[(0,z.jsxs)(`h3`,{className:`ccw-main-title`,children:[F.label,F.meta==null?null:(0,z.jsx)(`span`,{className:`count`,children:F.meta})]}),(0,z.jsx)(`div`,{className:`claudecode-workspace-save`,"data-visible":I?`true`:`false`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!I,tabIndex:I?0:-1,"aria-hidden":!I,onClick:()=>{N()},children:n(`common.save`)})})]}),(0,z.jsx)(`div`,{className:`ccw-body`,children:F.body})]})]})]})}function up(e,t,n){let r=t.trim().toLowerCase(),i=(r?e.filter(e=>e.label.toLowerCase().includes(r)||e.route.toLowerCase().includes(r)):e).toSorted((e,t)=>Number(!e.available)-Number(!t.available)),a=i.slice(0,n);return{total:e.length,showSearch:e.length>4,shown:a,hidden:i.length-a.length,noMatch:e.length>0&&i.length===0}}function dp(e){return new Set(Object.keys(e))}function fp(e,t){return t!==null&&e===t}function pp(e){return e||(typeof localStorage>`u`?void 0:localStorage)}function mp(e){return{read(t){let n=pp(t);if(!n)return null;try{let t=n.getItem(e);if(t===null)return null;let r=JSON.parse(t);return Array.isArray(r)?new Set(r.filter(e=>typeof e==`string`)):null}catch{return null}},write(t,n){let r=pp(n);if(r)try{r.setItem(e,JSON.stringify([...t]))}catch{}}}}function hp(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}var gp=[`opus`,`fable`,`sonnet`,`haiku`],_p=mp(`ocx.claudeDesktop.collapsedFamilies.v2`),vp={opus:`claudeDesktop.family.opus`,fable:`claudeDesktop.family.fable`,sonnet:`claudeDesktop.family.sonnet`,haiku:`claudeDesktop.family.haiku`};function yp(e){return{version:1,assignments:Object.fromEntries(Object.entries(e.assignments).map(([e,t])=>[e,{...t}])),defaults:{...e.defaults},...e.appliedFingerprint===void 0?{}:{appliedFingerprint:e.appliedFingerprint},...e.appliedAt===void 0?{}:{appliedAt:e.appliedAt}}}function bp(e){let t={...e.profile.assignments};for(let n of e.models){let e=t[n.route]??n.assignment;t[n.route]={family:gp.includes(e?.family)?e.family:`opus`,alias:typeof e?.alias==`string`?e.alias:``}}return{version:1,assignments:t,defaults:{opus:e.profile.defaults.opus??null,fable:e.profile.defaults.fable??null,sonnet:e.profile.defaults.sonnet??null,haiku:e.profile.defaults.haiku??null}}}function xp(e,t){return e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:t}function Sp(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):null}function Cp(e){return En(e)}function wp(e){let t=Cp(e);return{held:t,data:t?.data??null,profile:t?.profile??null,savedProfile:t?.profile?yp(t.profile):null,destinations:t?.data?Object.fromEntries(t.data.models.map(e=>[e.route,t.profile.assignments[e.route]?.family??`opus`])):{}}}function Tp({apiBase:e,active:t=!0,onPortChange:n}){let{t:r,locale:i}=Z(),a=je.find(e=>e.code===i)?.htmlLang,o=`ocx.claude-desktop.v1:${e}`,s=`claude-desktop:${e}`,c=(0,_.useMemo)(()=>wp(o),[o]),[l,u]=(0,_.useState)(()=>c.profile),[d,f]=(0,_.useState)(()=>c.savedProfile),[p,m]=(0,_.useState)(()=>c.destinations),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)({}),[w,T]=(0,_.useState)({}),[E,D]=(0,_.useState)(()=>_p.read()??new Set(gp)),[O,k]=(0,_.useState)({}),A=(0,_.useRef)(null),j=(0,_.useCallback)(async t=>{let n=await ct(await fetch(`${e}/api/claude-desktop`,{signal:t}),r(`claudeDesktop.loadFail`));if(!n||!(`profile`in n)||!(`models`in n))throw Error(xp(n,r(`claudeDesktop.loadFail`)));let i=bp(n),a={data:n,profile:i};if(t.aborted)throw Error(`Claude Desktop request aborted`);if(u(i),f(yp(i)),m(Object.fromEntries(n.models.map(e=>[e.route,i.assignments[e.route]?.family??`opus`]))),_p.read()===null){let e=Object.fromEntries(gp.map(e=>[e,0]));for(let t of n.models)e[i.assignments[t.route]?.family??`opus`]+=1;D(dp(e))}return Dn(o,a),a},[e,o,r,m,u,f]),M=bs(s,[e],j,{isEmpty:()=>!1,enabled:t,initialData:c.held??void 0}),N=M.state,P=N.data??(c.data&&c.profile?{data:c.data,profile:c.profile}:null),F=P?.data??null,I=l??P?.profile??null,L=d??P?.profile??null,R=P?Object.fromEntries(P.data.models.map(e=>[e.route,P.profile.assignments[e.route]?.family??`opus`])):{},B=Object.keys(p).length>0?p:R;(0,_.useEffect)(()=>{if(n){if(typeof F?.port==`number`){n(F.port);return}N.kind===`failed-cold`&&n(null)}},[F?.port,N.kind,n]);let V=(0,_.useMemo)(()=>I!==null&&L!==null&&JSON.stringify(I)!==JSON.stringify(L),[I,L]),H=(0,_.useMemo)(()=>{let e=Object.fromEntries(gp.map(e=>[e,[]]));if(!F||!I)return e;for(let t of F.models)e[I.assignments[t.route]?.family??`opus`].push(t);return e},[F,I]),U=(0,_.useMemo)(()=>{let e={};for(let t of gp){let n=H[t].filter(e=>e.available).map(e=>e.route).sort(),r=I?.defaults[t]??null;e[t]=r&&n.includes(r)?r:n[0]??null}return e},[H,I]),W=`ocx.claude-desktop.status.v1:${e}`,G=`claude-desktop-status:${e}`,ee=En(W),te=bs(G,[e],async t=>{let n=await lt(await fetch(`${e}/api/claude-desktop/status`,{signal:t}));if(!n)throw Error(`Claude Desktop status unavailable`);return Dn(W,n),n},{isEmpty:()=>!1,pollMs:5e3,enabled:t,initialData:ee??void 0}),K=te.state,q=K.data??ee??null,J=K.showError,Y=(e,t)=>{!I||I.assignments[e]?.family===t||(u(n=>{if(!n)return n;let r=n.assignments[e];if(!r||r.family===t)return n;let i={...n.assignments,[e]:{...r,family:t}},a={...n.defaults};return a[r.family]===e&&(a[r.family]=Object.keys(i).filter(t=>t!==e&&i[t].family===r.family).sort()[0]??null),a[t]===null&&(a[t]=e),{...n,assignments:i,defaults:a}}),m(n=>({...n,[e]:t})),y(r(`claudeDesktop.moved`,{route:e,family:r(vp[t])})))},ne=e=>{let t=hp(E,e);_p.write(t),D(t)},X=async t=>{if(!(!I||b)){x(`save`),g(null);try{await ct(await fetch(`${e}/api/claude-desktop`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:I})}),r(`claudeDesktop.saveFailed`)),f(yp(I)),t?(x(`apply`),(await ct(await fetch(`${e}/api/claude-desktop/apply`,{method:`POST`}),r(`claudeDesktop.applyFailed`)))?.saved===!1?(g({tone:`warn`,text:r(`claudeDesktop.appliedMarkerUnsaved`)}),y(r(`claudeDesktop.appliedMarkerUnsaved`))):(g({tone:`ok`,text:r(`claudeDesktop.savedApplied`)}),y(r(`claudeDesktop.savedAppliedAnnounce`)))):(g({tone:`ok`,text:r(`claudeDesktop.saved`)}),y(r(`claudeDesktop.savedAnnounce`))),te.refresh()}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.updateFailed`);g({tone:`err`,text:t}),y(t)}finally{x(null)}}},re=()=>{if(!I)return;let e=URL.createObjectURL(new Blob([`${JSON.stringify(I,null,2)}\n`],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`claude-desktop-profile.json`,t.click(),URL.revokeObjectURL(e),y(r(`claudeDesktop.exported`))},ie=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t)try{let e=JSON.parse(await t.text());if(e.version!==1||!e.assignments||!e.defaults)throw Error(r(`claudeDesktop.importExpected`));let n=bp({...F,profile:e});u(n),g({tone:`ok`,text:r(`claudeDesktop.importReady`)}),y(r(`claudeDesktop.importedAnnounce`))}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.importInvalid`);g({tone:`err`,text:t}),y(r(`claudeDesktop.importFailed`,{error:t}))}},ae=(e,t)=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);n&&Y(n,t)};if(N.kind===`disabled`&&!P)return null;if(N.showSkeleton&&!P)return(0,z.jsx)(Ss,{label:r(`claudeDesktop.loading`),rows:4});if(N.kind===`failed-cold`){let e=N.error instanceof Error?N.error.message:r(`claudeDesktop.loadFail`);return(0,z.jsxs)(`div`,{className:`claude-desktop-error`,children:[(0,z.jsx)($,{tone:`err`,children:e}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>M.refresh(),children:r(`claudeDesktop.retry`)})]})}return!F||!I?null:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`claude-desktop-toolbar`,children:(0,z.jsxs)(`div`,{className:`claude-profile-tools`,children:[(0,z.jsx)(`input`,{ref:A,type:`file`,accept:`application/json,.json`,hidden:!0,onChange:e=>void ie(e)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A.current?.click(),children:r(`claudeDesktop.importJson`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:re,children:r(`claudeDesktop.exportJson`)})]})}),(0,z.jsxs)(`div`,{className:`claude-status-bar ${J&&!q?`not-applied`:q?q.desiredEnabled?q.activeProfile===!1?`not-applied`:q.stale?`stale`:q.applied?`applied`:`not-applied`:`not-applied`:`pending`}`,"aria-busy":!q&&!J||void 0,children:[(0,z.jsx)(`span`,{className:`claude-status-dot`}),(0,z.jsx)(`span`,{children:J&&!q?r(`claudeDesktop.loadFail`):q?q.desiredEnabled?q.activeProfile===!1?r(`claudeDesktop.status.notActiveProfile`):q.stale?r(`claudeDesktop.status.stale`):q.applied?r(`claudeDesktop.status.applied`):r(`claudeDesktop.status.notApplied`):r(`claudeDesktop.status.disabled`):r(`claudeDesktop.loading`)}),q?.health.lastRequestAt&&(0,z.jsxs)(`span`,{className:`claude-status-health`,children:[r(`claudeDesktop.health.lastRequest`),`:`,` `,new Date(q.health.lastRequestAt).toLocaleTimeString(a)]}),q&&q.health.requestCount>0&&(0,z.jsx)(`span`,{className:`claude-status-health`,children:r(`claudeDesktop.health.stats`,{count:q.health.requestCount,errors:q.health.errorCount})})]}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:v}),h&&(0,z.jsx)($,{tone:h.tone,children:h.text}),N.showError&&(0,z.jsx)($,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),J&&q&&(0,z.jsx)($,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),(0,z.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,z.jsx)(`span`,{className:`claude-dirty${V?` active`:``}`,children:r(V?`claudeDesktop.unsaved`:`claudeDesktop.upToDate`)}),(0,z.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!V||b!==null,onClick:()=>void X(!1),children:r(b===`save`?`claudeDesktop.saving`:`common.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:b!==null,onClick:()=>void X(!0),children:b===`apply`?r(`claudeDesktop.applying`):b===`save`?r(`claudeDesktop.saving`):q?.desiredEnabled===!1?r(`claudeDesktop.enableApply`):r(`claudeDesktop.saveApply`)})]})]}),F.models.length===0&&(0,z.jsx)(it,{title:r(`claudeDesktop.emptyTitle`),children:r(`claudeDesktop.emptyHint`)}),(0,z.jsx)(`div`,{className:`ocx-group-stack`,"aria-label":r(`claudeDesktop.assignmentsLabel`),children:gp.map(e=>{let t=H[e],n=up(t,S[e]??``,w[e]??6),i=E.has(e),a=U[e];return(0,z.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`claude-lane-${e}`,onDragOver:e=>e.preventDefault(),onDrop:t=>ae(t,e),children:[(0,z.jsxs)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:[(0,z.jsx)(`h3`,{id:`claude-lane-${e}`,className:`ocx-group-heading`,children:(0,z.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`claude-lane-body-${e}`,onClick:()=>ne(e),children:[(0,z.jsx)(fe,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,z.jsx)(`span`,{className:`ocx-group-name`,children:r(vp[e])}),(0,z.jsx)(`span`,{className:`ocx-group-count`,children:r(t.length===1?`claudeDesktop.modelCountOne`:`claudeDesktop.modelCountMany`,{count:t.length})}),a&&(0,z.jsx)(`code`,{className:`claude-lane-default`,title:a,children:a})]})}),t.length>0&&I.defaults[e]===null&&(0,z.jsx)(`span`,{className:`claude-default-needed`,children:r(`claudeDesktop.chooseDefault`)}),a&&a!==I.defaults[e]&&(0,z.jsx)(`span`,{className:`claude-default-needed`,title:a,children:r(`claudeDesktop.temporaryDefault`)})]}),!i&&(0,z.jsxs)(`div`,{id:`claude-lane-body-${e}`,children:[n.showSearch&&(0,z.jsx)(`input`,{className:`input claude-lane-search`,type:`search`,placeholder:r(`models.search`),"aria-label":r(`models.search`),value:S[e]??``,onChange:t=>{let n=t.target.value;C(t=>({...t,[e]:n})),T(t=>({...t,[e]:6}))}}),(0,z.jsxs)(`div`,{className:`claude-lane-models`,children:[t.length===0?(0,z.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneEmpty`)}):n.noMatch?(0,z.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneNoMatch`)}):n.shown.map(t=>{let n=I.assignments[t.route],i=Sp(t.contextWindow,r),a=B[t.route]??`opus`,o=O[t.route]??fp(t.route,U[e]);return(0,z.jsxs)(`article`,{className:`claude-model-card${o?` open`:``}`,draggable:t.available,onDragStart:e=>{e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t.route)},children:[(0,z.jsxs)(`button`,{type:`button`,className:`claude-model-summary`,"aria-expanded":o,"aria-controls":`claude-model-body-${t.route}`,onClick:()=>k(e=>({...e,[t.route]:!o})),children:[(0,z.jsx)(fe,{className:`ocx-chevron`,width:12,height:12,"aria-hidden":`true`,style:{transform:o?`rotate(90deg)`:`none`}}),(0,z.jsxs)(`span`,{className:`claude-model-names`,children:[(0,z.jsx)(`strong`,{title:t.label,children:t.label}),(0,z.jsx)(`code`,{title:t.route,children:t.route})]}),i&&(0,z.jsx)(`span`,{className:`claude-model-context`,children:i}),!i&&(0,z.jsx)(`span`,{className:`claude-model-context claude-model-context-unknown`,children:r(`claudeDesktop.contextUnknown`)}),t.supports1m===!0&&(0,z.jsx)(`span`,{className:`claude-1m-chip`,children:r(`claudeDesktop.supports1m`)}),t.effortSupported===!1&&(0,z.jsx)(`span`,{className:`claude-effort-badge off`,children:r(`claudeDesktop.effort.displayOnly`)}),t.effortSupported===!0&&(0,z.jsx)(`span`,{className:`claude-effort-badge on`,children:r(`claudeDesktop.effort.supported`)}),I.defaults[e]===t.route&&(0,z.jsx)(`span`,{className:`claude-row-default`,children:r(`claudeDesktop.defaultBadge`)}),(0,z.jsx)(`span`,{className:`badge ${t.available?`badge-green`:`badge-muted`}`,children:t.available?r(`claudeDesktop.available`):r(`claudeDesktop.unavailable`)})]}),o&&(0,z.jsxs)(`div`,{className:`claude-model-body`,id:`claude-model-body-${t.route}`,children:[U[e]===t.route&&I.defaults[e]!==t.route&&(0,z.jsx)(`span`,{className:`claude-effective-default`,children:r(`claudeDesktop.temporaryDefault`)}),(0,z.jsxs)(`div`,{className:`claude-field`,children:[(0,z.jsx)(`span`,{children:r(`claudeDesktop.alias`)}),(0,z.jsx)(`code`,{className:`claude-alias`,title:n.alias,children:n.alias})]}),(0,z.jsxs)(`label`,{className:`claude-default-radio`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`default-${e}`,checked:I.defaults[e]===t.route,disabled:!t.available,onChange:()=>u(n=>n&&{...n,defaults:{...n.defaults,[e]:t.route}})}),r(`claudeDesktop.useAsDefault`,{family:r(vp[e])})]}),(0,z.jsxs)(`div`,{className:`claude-move-row`,children:[(0,z.jsx)(`label`,{htmlFor:`move-${t.route}`,children:r(`claudeDesktop.moveTo`)}),(0,z.jsx)(`select`,{id:`move-${t.route}`,className:`input`,value:a,disabled:!t.available,onChange:e=>m(n=>({...n,[t.route]:e.target.value})),children:gp.map(e=>(0,z.jsx)(`option`,{value:e,children:r(vp[e])},e))}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:!t.available||a===e,onClick:()=>Y(t.route,a),children:r(`claudeDesktop.move`)})]})]})]},t.route)}),n.hidden>0&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm claude-lane-more`,onClick:()=>T(t=>({...t,[e]:(t[e]??6)+6})),children:r(`models.showMore`,{n:n.hidden})})]})]})]},e)})})]})}var Ep=`integrations/claude`,Dp=`integrations/claude/desktop`;function Op(e=typeof window<`u`?window.location.hash:``){return Ve(e)===Dp?`desktop`:`code`}function kp(e){let t=En(`ocx.claude-desktop.v1:${e}`);return typeof t?.data?.port==`number`?t.data.port:null}function Ap({apiBase:e,active:t=!0}){let[n,r]=(0,_.useState)(Op),i=Q(),a=(0,_.useRef)(null),o=(0,_.useRef)(null),s=kp(e),[c,l]=(0,_.useState)(null),u=c?.base===e?c.port:s,d=c?.base===e,f=(0,_.useCallback)(t=>{l(n=>n?.base===e&&n.port===t?n:{base:e,port:t})},[e]);(0,_.useEffect)(()=>{let e=()=>r(Op());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let p=e=>{Ue(e===`desktop`?Dp:Ep),r(e),window.requestAnimationFrame(()=>{(e===`code`?a:o).current?.focus({preventScroll:!0})})},m=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),p(n===`code`?`desktop`:`code`)):e.key===`Home`?(e.preventDefault(),p(`code`)):e.key===`End`&&(e.preventDefault(),p(`desktop`))};return(0,z.jsxs)(`section`,{className:`claude-page`,children:[(0,z.jsxs)(`div`,{className:`claude-page-intro`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:i(n===`code`?`claude.pageTitle`:`claudeDesktop.title`)})}),n===`code`?(0,z.jsx)(`p`,{className:`page-sub`,children:i(`claude.subtitle`)}):(0,z.jsx)(`p`,{className:`page-sub`,children:u==null?i(d?`claudeDesktop.loadFail`:`claudeDesktop.loading`):i(`claudeDesktop.subtitle`,{port:u})})]}),(0,z.jsxs)(`div`,{className:`claude-tabs`,role:`tablist`,"aria-label":i(`claude.tabsLabel`),children:[(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:a,"aria-selected":n===`code`,"aria-controls":`claude-code-panel`,id:`claude-code-tab`,className:n===`code`?`active`:``,tabIndex:n===`code`?0:-1,onKeyDown:m,onClick:()=>p(`code`),children:i(`claude.tabCode`)}),(0,z.jsx)(`button`,{type:`button`,role:`tab`,ref:o,"aria-selected":n===`desktop`,"aria-controls":`claude-desktop-panel`,id:`claude-desktop-tab`,className:n===`desktop`?`active`:``,tabIndex:n===`desktop`?0:-1,onKeyDown:m,onClick:()=>p(`desktop`),children:i(`claude.tabDesktop`)})]}),(0,z.jsx)(`div`,{id:`claude-code-panel`,role:`tabpanel`,"aria-labelledby":`claude-code-tab`,hidden:n!==`code`,children:(0,z.jsx)(lp,{apiBase:e,active:t&&n===`code`},e)}),(0,z.jsx)(`div`,{id:`claude-desktop-panel`,role:`tabpanel`,"aria-labelledby":`claude-desktop-tab`,hidden:n!==`desktop`,children:(0,z.jsx)(Tp,{apiBase:e,active:t&&n===`desktop`,onPortChange:f},e)})]})}function jp(e,t,n,r){let i=e.filter(e=>r===`native`===e.native).map(e=>({...e,alias:t.get(e.id)??null,enabled:!n.has(e.id)})).toSorted((e,t)=>Number(!e.enabled)-Number(!t.enabled));return{rows:i,total:i.length,enabled:i.filter(e=>e.enabled).length}}var Mp=mp(`ocx.grok.collapsedGroups.v2`),Np=[{id:`native`,tkey:`grok.groupNative`},{id:`routed`,tkey:`grok.groupRouted`}],Pp=new Set(Np.map(e=>e.id));function Fp(e,t){return e?e>=1048576?t(`claudeDesktop.contextM`,{n:Math.round(e/1048576)}):e>=1e6?t(`claudeDesktop.contextM`,{n:e/1e6}):t(`claudeDesktop.contextK`,{n:Math.round(e/1e3)}):`—`}function Ip({apiBase:e,active:t=!0}){let n=Q(),r=`ocx.grok.status.v1:${e}`,i=En(r),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(()=>Mp.read()??new Set(Pp)),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(null),[p,m]=(0,_.useState)(``),h=(0,_.useCallback)(async t=>{let i=await ct(await fetch(`${e}/api/grok`,{signal:t}),n(`grok.loadFail`));if(!i)throw Error(n(`grok.loadFail`));let a={...i,candidates:i.candidates??[],excluded:i.excluded??[]};return Dn(r,a),a},[e,r,n]),g=`grok-status:${e}`,v=bs(g,[e],h,{isEmpty:()=>!1,initialData:i??void 0,enabled:t}),{state:y}=v,b=v.refresh,x=y.data??i,S=(0,_.useMemo)(()=>new Set(x?.excluded??[]),[x]),C=a??S,w=(0,_.useMemo)(()=>a!==null&&(a.size!==S.size||[...a].some(e=>!S.has(e))),[a,S]),T=(0,_.useMemo)(()=>new Map((x?.models??[]).map(e=>[e.id,e.alias])),[x]),E=e=>{let t=hp(s,e);Mp.write(t),c(t)},D=e=>{let t=e?new Set(Np.map(e=>e.id)):new Set;Mp.write(t),c(t)},O=(e,t)=>{o(n=>{let r=new Set(n??S);return t?r.delete(e):r.add(e),r})},k=async t=>{if(!l){u(`save`),f(null);try{await ct(await fetch(`${e}/api/grok/selection`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({excluded:[...C]})}),n(`grok.saveFailed`));let i=[...C];if(x&&L(g,{...x,excluded:i}),o(null),t){u(`apply`);let t=await fetch(`${e}/api/grok/apply`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??e.error??n(`grok.applyFailed`))}let r=await t.json().catch(()=>({}));r.skippedReason?(f({tone:`err`,text:r.message??n(`grok.applySkipped`)}),m(r.message??n(`grok.applySkipped`))):(f({tone:`ok`,text:n(`grok.savedApplied`)}),m(n(`grok.savedApplied`))),await b()}else f({tone:`ok`,text:n(`grok.saved`)}),m(n(`grok.saved`)),x&&Dn(r,{...x,excluded:i})}catch(e){let t=e instanceof Error?e.message:n(`grok.saveFailed`);f({tone:`err`,text:t}),m(t)}finally{u(null)}}};if(y.showSkeleton&&!x)return(0,z.jsx)(`section`,{className:`grok-page`,children:(0,z.jsx)(Ss,{label:n(`grok.loading`),rows:4})});if(y.kind===`failed-cold`){let e=y.error instanceof Error?y.error.message:n(`grok.loadFail`);return(0,z.jsxs)(`section`,{className:`grok-page`,children:[(0,z.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:e}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>b(),children:n(`common.retry`)})]})}return(0,z.jsxs)(`section`,{className:`grok-page`,"aria-busy":y.refreshing||void 0,children:[(0,z.jsx)(`h2`,{className:`page-title`,children:n(`grok.title`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`grok.subtitle`)}),(0,z.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:p}),d&&(0,z.jsx)($,{tone:d.tone,children:d.text}),y.showError&&(0,z.jsx)($,{tone:`err`,children:n(`grok.loadFail`)}),x&&x.candidates.length>0&&(0,z.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,z.jsx)(`span`,{className:`claude-dirty${w?` active`:``}`,children:n(w?`grok.unsaved`:`grok.upToDate`)}),(0,z.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!w||l!==null,onClick:()=>void k(!1),children:n(l===`save`?`grok.saving`:`common.save`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!w||l!==null,onClick:()=>void k(!0),children:n(l===`apply`?`grok.applying`:l===`save`?`grok.saving`:`grok.saveApply`)})]})]}),x?.present?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`grok-endpoint`,children:[(0,z.jsx)(`span`,{children:n(`grok.endpoint`)}),(0,z.jsx)(`code`,{children:x.baseUrl??`—`})]}),(0,z.jsx)(`p`,{className:`page-sub`,children:(0,z.jsx)(`code`,{children:x.configPath})})]}):(0,z.jsxs)(it,{title:n(`grok.notConfiguredTitle`),children:[n(`grok.notConfiguredHint`),(0,z.jsx)(`br`,{}),(0,z.jsx)(`code`,{children:x?.configPath})]}),x&&x.candidates.length>0&&(0,z.jsxs)(`div`,{className:`ocx-group-stack`,children:[(0,z.jsxs)(`div`,{className:`row`,style:{gap:6,margin:`2px 0 10px`},children:[(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>D(!0),disabled:l!==null,children:[(0,z.jsx)(fe,{width:12,height:12,"aria-hidden":`true`}),` `,n(`models.collapseAll`)]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>D(!1),disabled:l!==null,children:[(0,z.jsx)(fe,{width:12,height:12,"aria-hidden":`true`,style:{transform:`rotate(90deg)`}}),` `,n(`models.expandAll`)]})]}),Np.map(e=>{let t=jp(x.candidates,T,C,e.id);if(t.total===0)return null;let r=s.has(e.id);return(0,z.jsxs)(`section`,{className:`ocx-group${r?` collapsed`:``}`,"aria-labelledby":`grok-group-${e.id}`,children:[(0,z.jsx)(`header`,{className:`ocx-group-head${r?``:` open`}`,children:(0,z.jsx)(`h3`,{id:`grok-group-${e.id}`,className:`ocx-group-heading`,children:(0,z.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!r,"aria-controls":`grok-group-body-${e.id}`,onClick:()=>E(e.id),children:[(0,z.jsx)(fe,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:r?`none`:`rotate(90deg)`}}),(0,z.jsx)(`span`,{className:`ocx-group-name`,children:n(e.tkey)}),(0,z.jsx)(`span`,{className:`ocx-group-count`,children:n(`grok.enabledCount`,{on:t.enabled,total:t.total})})]})})}),!r&&(0,z.jsx)(`div`,{id:`grok-group-body-${e.id}`,className:`grok-model-list`,children:t.rows.map(e=>(0,z.jsxs)(`div`,{className:`grok-model-row`,children:[(0,z.jsx)(tt,{on:e.enabled,onClick:()=>O(e.id,!e.enabled),disabled:l!==null,label:n(`grok.toggleModel`,{id:e.id})}),(0,z.jsxs)(`span`,{className:`grok-model-names`,children:[(0,z.jsx)(`strong`,{title:e.id,children:e.id}),(0,z.jsx)(`code`,{title:e.alias??void 0,children:e.alias??`—`})]}),(0,z.jsx)(`span`,{className:`claude-model-context`,children:Fp(e.contextWindow,n)})]},e.id))})]},e.id)})]})]})}function Lp({copyKey:e,vars:t}){let n=Q()(e,t),r=t?.path;if(!r||!n.includes(r))return(0,z.jsx)(`p`,{children:n});let[i,...a]=n.split(r);return(0,z.jsxs)(`p`,{children:[i,(0,z.jsx)(`code`,{children:r}),a.join(r)]})}function Rp({copy:e,onConfirm:t,onClose:n}){let r=Q(),i=(0,_.useRef)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),l=`integration-consequence-dialog-title`;(0,_.useEffect)(()=>{let e=i.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]);let u=(0,_.useCallback)(e=>{e.preventDefault(),a||n()},[n,a]),d=(0,_.useCallback)(async()=>{if(!a){o(!0),c(null);try{await t()}catch(e){c(e instanceof Error?e.message:r(`integrations.error.generic`)),o(!1)}}},[t,a,r]),f=[(0,z.jsx)(Lp,{copyKey:e.changesKey,vars:e.vars},`changes`),(0,z.jsx)(Lp,{copyKey:e.breakageKey,vars:e.vars},`breakage`),(0,z.jsx)(Lp,{copyKey:e.undoKey,vars:e.vars},`undo`)];return e.sideEffectKey&&f.push((0,z.jsx)(Lp,{copyKey:e.sideEffectKey,vars:e.vars},`side-effect`)),(0,z.jsxs)(`dialog`,{ref:i,className:`modal-overlay`,"aria-labelledby":l,onCancel:u,children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":r(`common.close`),tabIndex:-1,onClick:()=>{a||n()}}),(0,z.jsxs)(`div`,{className:`modal-card integration-consequence-dialog`,role:`document`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsx)(`h3`,{id:l,children:r(e.titleKey,e.vars)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:n,disabled:a,children:r(`common.close`)})]}),(0,z.jsx)(`div`,{className:`integration-consequence-body`,children:f}),s&&(0,z.jsx)($,{tone:`err`,children:s}),(0,z.jsx)(`div`,{className:`modal-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>void d(),disabled:a,children:r(e.confirmKey)})})]})]})}var zp=[`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`],Bp=new Set([`not_installed`,`conflict`,`unsafe`,`non_loopback`,`drift_requires_confirm`,`snapshot_expired`,`write_failed`]),Vp=new Set([`integration_unsafe`,`integration_conflict`,`integration_drift_confirmation_required`,`integration_snapshot_expired`,`integration_mutation_failed`]),Hp=new Set([`absent`,`current`,`stale`,`conflict`,`unsafe`]);function Up(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Wp(e){return!Up(e)||!Bp.has(String(e.reason))?!1:typeof e.error==`string`&&Vp.has(String(e.code))&&zp.includes(e.clientId)&&Hp.has(String(e.state))&&typeof e.message==`string`}var Gp=class extends Error{refusal;status;body;constructor(e,t){let n=Wp(t)?t:null;super(n?.message??t.error??t.message??String(e)),this.name=`IntegrationApiError`,this.status=e,this.body=t,this.refusal=n}};async function Kp(e){try{let t=await e.json();return Up(t)?t:{}}catch{return{}}}async function qp(e){if(!e.ok)throw new Gp(e.status,await Kp(e));let t=await lt(e);if(t==null)throw new Gp(e.status,{});return t}async function Jp(e,t){return qp(await fetch(`${e}/api/client-integrations`,{signal:t}))}async function Yp(e,t,n){return qp(await fetch(`${e}/api/client-integrations/${encodeURIComponent(t)}`,{signal:n}))}async function Xp(e,t,n){let r=t?`?client=${encodeURIComponent(t)}`:``;return qp(await fetch(`${e}/api/client-integrations/journal${r}`,{signal:n}))}async function Zp(e,t,n,r){return qp(await fetch(`${e}/api/client-integrations/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n}),signal:r}))}async function Qp(e,t,n=!1,r){return qp(await fetch(`${e}/api/client-integrations/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({opId:t,confirmDrift:n}),signal:r}))}async function $p(e){try{let t=await e;return t.ok?await lt(t)??null:null}catch{return null}}async function em(e,t){let n=await $p(fetch(`${e}/api/startup-health`,{signal:t}));return n?{routingInjected:n.routingInjected===!0,status:typeof n.status==`string`?n.status:void 0,recommendedCommand:typeof n.recommendedCommand==`string`?n.recommendedCommand:null}:null}async function tm(e,t){let n=await fetch(`${e}/api/keys`,{signal:t});if(!n.ok)throw Error(`/api/keys responded ${n.status}`);let r=await lt(n);if(!r||!Array.isArray(r.keys))throw Error(`/api/keys returned an unexpected body`);return r.keys.length}async function nm(e,t){let n=await $p(fetch(`${e}/api/claude-code`,{signal:t}));return n?{enabled:n.enabled===!0,authMode:typeof n.authMode==`string`?n.authMode:void 0}:null}async function rm(e,t){let n=await $p(fetch(`${e}/api/claude-desktop/status`,{signal:t}));return!n||typeof n.desiredEnabled!=`boolean`||typeof n.installed!=`boolean`||typeof n.observedKind!=`string`?null:{desiredEnabled:n.desiredEnabled,installed:n.installed,observedKind:n.observedKind,applied:n.applied===!0,stale:n.stale===!0,activeProfile:typeof n.activeProfile==`boolean`?n.activeProfile:null,appliedAt:typeof n.appliedAt==`string`?n.appliedAt:null}}async function im(e,t){let n=await $p(fetch(`${e}/api/grok`,{signal:t}));return n?{present:n.present===!0,models:Array.isArray(n.models)?n.models:[]}:null}var am=new Set([`claude`,`grok`,`codex`,`claude-desktop`]),om=new Set([`native_integration_refused`,`native_integration_failed`]),sm=new Set([`not_installed`,`orphaned_marker`,`home_mismatch`,`config_busy`,`write_failed`,`metadata_unreadable`,`cleanup_incomplete`,`desired_state_changed`]);function cm(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lm(e){return cm(e)?typeof e.error==`string`&&om.has(String(e.code))&&am.has(String(e.clientId))&&sm.has(String(e.reason))&&typeof e.message==`string`:!1}var um=class extends Error{refusal;status;body;constructor(e,t){let n=lm(t)?t:null;super(n?.message??t.error??t.message??String(e)),this.name=`NativeApiError`,this.status=e,this.body=t,this.refusal=n}};async function dm(e){try{let t=await e;return t.ok?await lt(t)??null:null}catch{return null}}async function fm(e){try{let t=await e.json();return cm(t)?t:{}}catch{return{}}}async function pm(e){if(!e.ok)throw new um(e.status,await fm(e));let t=await lt(e);if(t==null)throw new um(e.status,{});return t}function mm(e,t){return dm(fetch(`${e}/api/native-integrations`,{signal:t}))}async function hm(e,t,n,r){return pm(await fetch(`${e}/api/native-integrations/${encodeURIComponent(t)}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:n}),signal:r}))}var gm={integration_mutation_busy:`integrations.error.busy`};function _m(e){return e instanceof Gp?e.refusal:null}function vm(e){return e instanceof um?e.refusal:null}function ym(e){return e===`conflict`?`integrations.error.conflict`:e===`unsafe`?`integrations.error.unsafe`:e===`non_loopback`?`integrations.error.nonLoopback`:`integrations.error.generic`}var bm=new Set([`non_loopback`]);function xm(e,t,n){return t.reason===`orphaned_marker`?e(`integrations.native.error.orphanedMarker`,{path:n??``}):t.reason===`home_mismatch`?`${e(`integrations.native.error.homeMismatch`)} ${t.message}`:t.reason===`not_installed`?e(`integrations.native.error.notInstalled`):t.reason===`config_busy`?e(`integrations.native.error.configBusy`):t.reason===`metadata_unreadable`?e(`integrations.native.error.desktopUnsafeMetadata`,{path:n??``}):t.reason===`cleanup_incomplete`?e(`integrations.native.error.desktopCleanupIncomplete`,{paths:(t.residualPaths??[]).join(`, `)}):t.message||e(`integrations.error.generic`)}function Sm(e,t,n,r){let i=vm(t);if(i)return xm(e,i,r);let a=_m(t);if(!a){let r=gm[t instanceof Gp?String(t.body.code??``):``];return r?e(r):t instanceof Error&&t.message?t.message:n??e(`integrations.error.generic`)}let o=bm.has(a.reason)?e(ym(a.reason),{client:a.clientId}):a.message||e(ym(a.reason));return a.snapshotPath?e(a.residual?`integrations.error.residual`:`integrations.error.recover`,{message:o,path:a.snapshotPath}):a.reason===`conflict`||a.reason===`unsafe`?`${e(ym(a.reason))} ${o}`:o}var Cm={titleKey:`integrations.codex.dialog.native.title`,changesKey:`integrations.codex.dialog.native.changes`,breakageKey:`integrations.codex.dialog.native.breakage`,undoKey:`integrations.codex.dialog.native.undo`,confirmKey:`integrations.codex.dialog.native.confirm`},wm={titleKey:`integrations.codex.dialog.routed.title`,changesKey:`integrations.codex.dialog.routed.changes`,breakageKey:`integrations.codex.dialog.routed.breakage`,undoKey:`integrations.codex.dialog.routed.undo`,confirmKey:`integrations.codex.dialog.routed.confirm`};function Tm(e){return e===`cold`||e===`retrying-cold`}function Em({apiBase:e,active:t=!0}){let n=Q(),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),d=(0,_.useCallback)(async t=>(await mm(e,t))?.clients.find(e=>e.clientId===`codex`)??null,[e]),f=(0,_.useCallback)(t=>em(e,t),[e]),p=bs(`integration-codex-mode:${e}`,[e],d,{isEmpty:e=>e===null,enabled:t}),m=bs(`integration-codex-routing-detail:${e}`,[e],f,{isEmpty:e=>e===null,enabled:t}),h=p.state.data??null,g=m.state.data??null,v=h?.desiredEnabled===!1?`native`:`routed`,y=s!==null&&(h===s.status||g===s.routing),b=y?s.mode:v,x=y?s.mode===`routed`:g?.routingInjected===!0,S=!Tm(p.state.kind)&&!Tm(m.state.kind)&&(!h||!g),C=b===`native`&&!x||b===`routed`&&x,w=()=>{p.refresh(),m.refresh()},T=async t=>{if(!(r||t===b)){i(t),u(null);try{let r=await hm(e,`codex`,t===`routed`);if(!(t===`routed`?r.state===`current`:r.state===`absent`)){u({tone:`err`,text:r.message});return}c({mode:t,status:h,routing:g}),u({tone:`ok`,text:n(t===`native`?`integrations.codex.result.native`:`integrations.codex.result.routed`)}),w()}catch(e){u({tone:`err`,text:Sm(n,e,n(`integrations.error.generic`),h?.configPath)})}finally{i(null)}}},E=e=>{r||e===b||o(e)};return Tm(p.state.kind)||Tm(m.state.kind)?(0,z.jsx)(`section`,{className:`codex-integration-page`,children:(0,z.jsx)(`p`,{className:`page-sub`,children:n(`common.loading`)})}):(0,z.jsxs)(`section`,{className:`codex-integration-page`,"aria-labelledby":`codex-integration-title`,children:[(0,z.jsxs)(`div`,{className:`codex-integration-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h3`,{id:`codex-integration-title`,children:n(`integrations.codex.title`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.codex.body`)})]}),!S&&(0,z.jsx)(`span`,{className:`badge ${C?`badge-green`:`badge-warn`}`,children:n(C?`integrations.codex.status.ready`:`integrations.codex.status.attention`)})]}),S&&(0,z.jsx)($,{tone:`err`,children:n(`integrations.codex.status.unavailable`)}),!S&&!C&&(0,z.jsx)($,{tone:`warn`,children:n(`integrations.codex.status.mismatch`)}),l&&(0,z.jsx)($,{tone:l.tone,children:l.text}),(0,z.jsxs)(`div`,{className:`codex-mode-grid`,"aria-label":n(`integrations.codex.modeLabel`),children:[(0,z.jsxs)(`article`,{className:`codex-mode-card${b===`native`?` codex-mode-card--selected`:``}`,children:[(0,z.jsxs)(`div`,{className:`codex-mode-card-head`,children:[(0,z.jsx)(`h4`,{children:n(`integrations.codex.native.title`)}),(0,z.jsx)(`span`,{className:`badge badge-accent`,children:n(`integrations.codex.recommended`)})]}),(0,z.jsx)(`p`,{children:n(`integrations.codex.native.body`)}),(0,z.jsxs)(`ul`,{children:[(0,z.jsx)(`li`,{children:n(`integrations.codex.native.account`)}),(0,z.jsx)(`li`,{children:n(`integrations.codex.native.android`)}),(0,z.jsx)(`li`,{children:n(`integrations.codex.native.config`)})]}),(0,z.jsx)(`button`,{type:`button`,className:b===`native`?`btn btn-ghost`:`btn btn-primary`,"aria-pressed":b===`native`,disabled:r!==null||S||b===`native`,onClick:()=>E(`native`),children:n(b===`native`?`integrations.codex.current`:r===`native`?`integrations.codex.switching`:`integrations.codex.native.use`)})]}),(0,z.jsxs)(`article`,{className:`codex-mode-card${b===`routed`?` codex-mode-card--selected`:``}`,children:[(0,z.jsxs)(`div`,{className:`codex-mode-card-head`,children:[(0,z.jsx)(`h4`,{children:n(`integrations.codex.routed.title`)}),b===`routed`&&(0,z.jsx)(`span`,{className:`badge badge-green`,children:n(`integrations.codex.current`)})]}),(0,z.jsx)(`p`,{children:n(`integrations.codex.routed.body`)}),(0,z.jsxs)(`ul`,{children:[(0,z.jsx)(`li`,{children:n(`integrations.codex.routed.models`)}),(0,z.jsx)(`li`,{children:n(`integrations.codex.routed.config`)}),(0,z.jsx)(`li`,{children:n(`integrations.codex.routed.restore`)})]}),(0,z.jsx)(`button`,{type:`button`,className:b===`routed`?`btn btn-ghost`:`btn btn-primary`,"aria-pressed":b===`routed`,disabled:r!==null||S||b===`routed`,onClick:()=>E(`routed`),children:n(b===`routed`?`integrations.codex.current`:r===`routed`?`integrations.codex.switching`:`integrations.codex.routed.use`)})]})]}),(0,z.jsxs)(`div`,{className:`codex-protection-panel`,children:[(0,z.jsx)(`h4`,{children:n(`integrations.codex.protection.title`)}),(0,z.jsx)(`p`,{children:n(`integrations.codex.protection.body`)}),h?.configPath&&(0,z.jsx)(`code`,{children:h.configPath}),(0,z.jsxs)(`ol`,{children:[(0,z.jsx)(`li`,{children:n(`integrations.codex.protection.snapshot`)}),(0,z.jsx)(`li`,{children:n(`integrations.codex.protection.comments`)}),(0,z.jsx)(`li`,{children:n(`integrations.codex.protection.restore`)})]})]}),(0,z.jsxs)(`div`,{className:`codex-native-help`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h4`,{children:n(`integrations.codex.login.title`)}),(0,z.jsxs)(`p`,{children:[n(`integrations.codex.login.body`),` `,(0,z.jsx)(`code`,{children:`codex login`})]})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>Ue(`android-remote`),children:n(`integrations.codex.openAndroid`)})]}),a&&(0,z.jsx)(Rp,{copy:{...a===`native`?Cm:wm,vars:{path:h?.configPath??``}},onClose:()=>o(null),onConfirm:async()=>{await T(a),o(null)}})]})}var Dm={"not-installed":`integrations.state.notInstalled`,unknown:`integrations.state.unknown`,absent:`integrations.state.absent`,current:`integrations.state.current`,stale:`integrations.state.stale`,conflict:`integrations.state.conflict`,unsafe:`integrations.state.unsafe`},Om={"not-installed":`badge badge-muted`,unknown:`badge badge-muted`,absent:`badge badge-muted`,current:`badge badge-green`,stale:`badge badge-amber`,conflict:`badge integration-badge--danger`,unsafe:`badge integration-badge--danger-outline`};function km({state:e,installed:t,id:n}){let r=Q(),i=e===`unknown`||e===`not-installed`||t?e:`not-installed`;return(0,z.jsx)(`span`,{id:n,className:Om[i],"data-integration-state":i,children:r(Dm[i])})}function Am({apiBase:e,row:t,onClose:n,onRestored:r}){let i=Q(),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),d=async()=>{if(!s){c(!0),u(null);try{await Qp(e,t.opId,a),r(),n()}catch(e){if(_m(e)?.reason===`drift_requires_confirm`){o(!0),c(!1);return}u(Sm(i,e)),c(!1)}}};return(0,z.jsx)(`dialog`,{className:`modal-overlay`,open:!0,style:{display:`flex`,border:`none`,margin:0,maxWidth:`none`,maxHeight:`none`,width:`100%`,height:`100%`},"aria-labelledby":`integration-restore-title`,onCancel:e=>{e.preventDefault(),n()},children:(0,z.jsxs)(`div`,{className:`modal-card integration-restore-dialog`,children:[(0,z.jsx)(`div`,{className:`modal-head`,children:(0,z.jsx)(`h3`,{id:`integration-restore-title`,children:i(a?`integrations.restore.driftTitle`:`integrations.restore.title`)})}),(0,z.jsx)(`div`,{className:`modal-desc`,children:i(a?`integrations.restore.driftBody`:`integrations.restore.body`)}),(0,z.jsx)(`p`,{className:`integration-path`,children:t.configPath}),l&&(0,z.jsx)($,{tone:`err`,children:l}),(0,z.jsxs)(`div`,{className:`modal-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:n,disabled:s,children:i(`common.cancel`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>void d(),disabled:s,children:i(s?`integrations.restore.pending`:a?`integrations.restore.confirmDrift`:`integrations.restore.confirm`)})]})]})})}function jm(e){return e.replace(/(^|(?:&&|\|\||;)\s*)ocx(?=\s|$)/gm,`$1rmx`).replace(/(^|[\\/])\.opencodex(?=([\\/]|$))/g,`$1.remodex`)}var Mm={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`};function Nm(e){return e===`current`||e===`stale`}function Pm(e){let t={id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`,toggle:`codex`,toggleBlocked:null,togglePath:null,status:null,detail:null,detailVars:null};return e?e.routingInjected===!0?{...t,state:e.status===`error`?`stale`:`current`,installed:!0,applied:!0,detailKey:`integrations.detail.codexRouted`}:{...t,state:`absent`,installed:!0,applied:!1,detail:e.recommendedCommand?jm(e.recommendedCommand):null,detailKey:e.recommendedCommand?null:`integrations.detail.codexAbsent`}:{...t,state:`unknown`,installed:!1,applied:!1,detailKey:null}}function Fm(e,t){let n={hash:`integrations/keys`,labelKey:`integrations.tab.keys`};return e===`checking`?{...n,state:`checking`,detailKey:`integrations.detail.keyChecking`,detailVars:null}:e===`unavailable`||t===null?{...n,state:`unavailable`,detailKey:`integrations.detail.keyUnavailable`,detailVars:null}:{...n,state:t>0?`issued`:`none-issued`,detailKey:t>0?`integrations.detail.keyCount`:`integrations.detail.keyNone`,detailVars:t>0?{count:String(t)}:null}}function Im(e){return e?e.enabled===!0?e.authMode===`subscription`?`claude.authModeSubscription`:e.authMode===`proxy`?`claude.authModeProxy`:e.authMode===`auto`?`claude.authModeAuto`:null:`integrations.detail.claudeOff`:null}function Lm(e,t,n){let r={id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`,toggle:`claude`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null,detailVars:null},i=Im(e);if(n===void 0){if(!e)return{...r,state:`unknown`,installed:!1,applied:!1,detailKey:i};let t=e.enabled===!0;return{...r,state:t?`current`:`absent`,installed:!0,applied:t,detailKey:i}}return n?t?{...r,state:t.state,installed:t.installed,applied:t.state===`current`,detailKey:i}:{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,detailKey:i}:{...r,state:`unknown`,installed:!1,applied:!1,detailKey:i}}function Rm(e,t,n){let r={id:`claudeDesktop`,hash:`integrations/claude/desktop`,labelKey:`claudeDesktop.title`,toggle:`claude-desktop`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null,detailVars:null};if(!e||!n||!t||typeof e.desiredEnabled!=`boolean`)return{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,detailKey:null};let i=e.desiredEnabled;if(e.applied!==!0)return{...r,state:`absent`,installed:e.installed===!0,applied:!1,toggleOn:i,detailKey:i?`integrations.detail.desktopDesiredOnNotApplied`:`integrations.detail.desktopDesiredOff`};let a=e.stale===!0||e.activeProfile===!1;return{...r,state:a?`stale`:`current`,installed:!0,applied:!0,toggleOn:i,detailKey:e.activeProfile===!1?`integrations.detail.desktopNotServed`:a?`integrations.detail.desktopStale`:`integrations.detail.desktopCurrent`}}function zm(e){if(!e)return{detailKey:null,detailVars:null};let t=e.present===!0;return{detailKey:t?`integrations.detail.grokModels`:`integrations.detail.grokAbsent`,detailVars:t?{count:String(e.models?.length??0)}:null}}function Bm(e,t,n){let r={id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`,toggle:`grok`,toggleBlocked:t?.disableBlocked??null,togglePath:t?.configPath??null,status:null,detail:null},i=zm(e);if(n===void 0){if(!e)return{...r,state:`unknown`,installed:!1,applied:!1,...i};let t=e.present===!0;return{...r,state:t?`current`:`absent`,installed:t,applied:t,...i}}return n?t?{...r,state:t.state,installed:t.installed,applied:t.state===`current`,...i}:{...r,toggle:null,state:`unknown`,installed:!1,applied:!1,...i}:{...r,state:`unknown`,installed:!1,applied:!1,...i}}function Vm(e){return{id:e.clientId,hash:`integrations/${e.clientId}`,labelKey:Mm[e.clientId],state:e.installed?e.state:`not-installed`,installed:e.installed,applied:e.installed&&Nm(e.state),detail:e.configPath,detailKey:null,detailVars:null,toggle:e.clientId,toggleBlocked:null,togglePath:e.configPath,status:e}}function Hm(e){let t=e.native?.find(e=>e.clientId===`claude`),n=e.native?.find(e=>e.clientId===`grok`),r=new Map(e.clients.map(e=>[e.clientId,e])),i=[Pm(e.codex),Lm(e.claude,t,e.nativeSettled),Rm(e.claudeDesktop,e.native?.find(e=>e.clientId===`claude-desktop`),e.nativeSettled),Bm(e.grok,n,e.nativeSettled)];for(let t of zp){let n=r.get(t);if(n){i.push(Vm(n));continue}e.clientsSettled||i.push({id:t,hash:`integrations/${t}`,labelKey:Mm[t],state:`unknown`,installed:!1,applied:!1,detail:null,detailKey:null,detailVars:null,toggle:null,toggleBlocked:null,togglePath:null,status:null})}return{keysRow:Fm(e.keyPhase,e.keyCount),rows:i}}function Um(e){return{detected:e.filter(e=>e.installed).length,applied:e.filter(e=>e.applied).length,stale:e.filter(e=>e.state===`stale`).length,unknown:e.filter(e=>e.state===`unknown`).length}}var Wm={titleKey:`integrations.dialog.grok.title`,changesKey:`integrations.dialog.grok.changes`,breakageKey:`integrations.dialog.grok.breakage`,undoKey:`integrations.dialog.grok.undo`,confirmKey:`integrations.dialog.grok.confirm`},Gm={titleKey:`integrations.dialog.desktop.title`,changesKey:`integrations.dialog.desktop.changes`,breakageKey:`integrations.dialog.desktop.breakage`,undoKey:`integrations.dialog.desktop.undo`,sideEffectKey:`integrations.dialog.desktop.restart`,confirmKey:`integrations.dialog.desktop.confirm`},Km={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`};function qm(e){return e.state===`current`||e.state===`stale`}function Jm({row:e,pending:t,result:n,onOpen:r,onToggle:i}){let a=Q(),o=e.detail??(e.detailKey?a(e.detailKey,e.detailVars??void 0):null),s=e.toggleBlocked!==null&&(e.applied||e.toggleBlocked.reason===`orphaned_marker`),c=s&&e.toggleBlocked&&(e.toggle===`claude`||e.toggle===`grok`)?Sm(a,new um(409,{error:`native integration change refused`,code:`native_integration_refused`,clientId:e.toggle,reason:e.toggleBlocked.reason,message:e.toggleBlocked.message}),void 0,e.togglePath??void 0):null;return(0,z.jsxs)(`li`,{className:`integration-card`,"data-client":e.id,children:[(0,z.jsxs)(`div`,{className:`integration-card-head`,children:[(0,z.jsx)(`h4`,{children:(0,z.jsx)(`button`,{type:`button`,className:`integration-card-link`,onClick:r,children:a(e.labelKey)})}),(0,z.jsx)(km,{state:e.state,installed:e.installed})]}),o&&(0,z.jsx)(`p`,{className:e.detail?`integration-path`:`integration-meta`,children:o}),n?.tone===`err`&&(0,z.jsx)($,{tone:`err`,children:n.text}),n?.tone===`ok`&&(0,z.jsx)($,{tone:`ok`,children:n.text}),(0,z.jsxs)(`div`,{className:`integration-card-actions`,children:[e.toggle&&i&&(0,z.jsxs)(`div`,{className:`integration-toggle-control`,children:[(0,z.jsx)(tt,{on:e.toggleOn??e.applied,onClick:i,disabled:e.state===`unknown`||!e.installed||e.state===`conflict`||e.state===`unsafe`||s||t,label:e.applied?a(`integrations.action.disable`):a(`integrations.action.apply`)}),c&&(0,z.jsx)(`p`,{className:`integration-toggle-blocked`,children:c})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:r,tabIndex:-1,children:a(`integrations.action.settings`)})]})]})}function Ym({apiBase:e,active:t=!0}){let n=Q(),[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)({}),[d,f]=(0,_.useState)(null),p=(0,_.useRef)(null);(0,_.useEffect)(()=>{if(d!==null)return;let e=p.current;e&&(p.current=null,e.isConnected&&e.focus())},[d]);let m=(0,_.useCallback)(async t=>(await Jp(e,t)).clients,[e]),h=(0,_.useCallback)(async t=>(await Xp(e,void 0,t)).operations,[e]),g=(0,_.useCallback)(t=>em(e,t),[e]),v=(0,_.useCallback)(t=>tm(e,t),[e]),y=(0,_.useCallback)(t=>nm(e,t),[e]),b=(0,_.useCallback)(t=>rm(e,t),[e]),x=(0,_.useCallback)(t=>im(e,t),[e]),S=(0,_.useCallback)(async t=>(await mm(e,t))?.clients??null,[e]),C=bs(`integration-states:${e}`,[e],m,{isEmpty:e=>e.length===0,enabled:t}),w=bs(`integration-journal-all:${e}`,[e],h,{isEmpty:e=>e.length===0,enabled:t}),T=bs(`integration-codex:${e}`,[e],g,{isEmpty:e=>e===null,enabled:t}),E=bs(`integration-keys:${e}`,[e],v,{isEmpty:()=>!1,enabled:t}),D=bs(`integration-claude:${e}`,[e],y,{isEmpty:e=>e===null,enabled:t}),O=bs(`integration-claude-desktop:${e}`,[e],b,{isEmpty:e=>e===null,enabled:t}),k=bs(`integration-grok:${e}`,[e],x,{isEmpty:e=>e===null,enabled:t}),A=bs(`integration-native:${e}`,[e],S,{isEmpty:e=>e===null,enabled:t}),j=C.state.data??[],M=w.state.data??[],N=j.filter(qm),P=j.filter(e=>e.installed),F=C.state.kind!==`cold`&&C.state.kind!==`retrying-cold`,I=A.state.data??null,L=I!==null,R=E.state.kind===`cold`||E.state.kind===`retrying-cold`?`checking`:E.state.kind===`failed-cold`||E.state.kind===`failed-with-stale`?`unavailable`:`settled`,{keysRow:B,rows:V}=Hm({clients:j,clientsSettled:F,codex:T.state.data??null,keyCount:E.state.data??null,keyPhase:R,claude:D.state.data??null,claudeDesktop:O.state.data??null,grok:k.state.data??null,native:I,nativeSettled:L}),H=Um(V),U=()=>{C.refresh(),w.refresh(),T.refresh(),E.refresh(),D.refresh(),O.refresh(),k.refresh(),A.refresh()},W=async()=>{if(r||N.length===0)return;let t=[n(`integrations.bulk.title`),n(`integrations.bulk.body`)].join(`
70
70
 
71
- `);if(!confirm(t))return;i(!0),o(null);let a=[];for(let t of N)try{await Zp(e,t.clientId,!1)}catch(e){a.push(`${t.clientId}: ${Sm(n,e)}`)}let s=!1;try{s=(await Jp(e)).clients.some(qm)}catch{a.push(n(`integrations.error.stale`))}s&&a.length===0&&a.push(n(`integrations.error.stale`)),U(),i(!1),o(a.length===0?{tone:`ok`,text:n(`integrations.bulk.success`)}:{tone:`err`,text:n(`integrations.bulk.partial`,{clients:a.join(`; `)})})},G=M[0]?.at,[ee,te]=(0,_.useState)(null),K=()=>{A.refresh(),D.refresh(),k.refresh()},q=(e,t)=>{u(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},J=async(t,r)=>{if(!ee&&t.toggle){te(t.id),q(t.id,null);try{if(t.status)await Zp(e,t.status.clientId,r),U();else if(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`){let i=await hm(e,t.toggle,r);i.reason===`non_loopback_removed`?q(t.id,{tone:`ok`,text:n(i.changed?`integrations.native.msg.nonLoopbackRemoved`:`integrations.native.msg.nonLoopbackRemovedNoop`)}):i.reason===`non_loopback_superseded`&&q(t.id,{tone:`ok`,text:n(`integrations.native.msg.nonLoopbackSuperseded`)}),K()}}catch(e){q(t.id,{tone:`err`,text:Sm(n,e,void 0,t.togglePath??void 0)}),(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`)&&K()}finally{te(null)}}},Y=(e,t)=>{if(e.status||t||e.id===`claude`||e.toggle===null){J(e,t);return}let n=document.activeElement;p.current=n?.tagName===`BUTTON`?n:null,f(e)};return(0,z.jsxs)(`section`,{className:`integrations-overview`,children:[(0,z.jsxs)(`div`,{className:`integration-summary`,children:[(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.detected`)}),(0,z.jsx)(`strong`,{children:H.detected})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.applied`)}),(0,z.jsx)(`strong`,{children:H.applied})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.stale`)}),(0,z.jsx)(`strong`,{children:H.stale})]}),H.unknown>0&&(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.state.unknown`)}),(0,z.jsx)(`strong`,{children:H.unknown})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.lastChange`)}),(0,z.jsx)(`strong`,{children:G?new Date(G).toLocaleString():n(`integrations.status.unknown`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void W(),disabled:r||N.length===0,children:n(`integrations.summary.disableAll`)})]}),(0,z.jsx)(Xm,{row:B}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.onboarding`)}),C.state.kind===`failed-cold`&&(0,z.jsx)($,{tone:`err`,children:n(`integrations.error.load`)}),C.state.kind===`failed-with-stale`&&(0,z.jsx)($,{tone:`err`,children:n(`integrations.error.stale`)}),a&&(0,z.jsx)($,{tone:a.tone,children:a.text}),V.length===0?C.state.kind===`failed-cold`?null:(0,z.jsx)(`p`,{className:`page-sub`,children:n(`common.loading`)}):(0,z.jsx)(`ul`,{className:`integration-cards`,children:V.map(e=>(0,z.jsx)(Jm,{row:e,pending:ee!==null,result:l[e.id]??null,onOpen:()=>Ue(e.hash),onToggle:e.toggle?()=>Y(e,!(e.toggleOn??e.applied)):null},e.id))}),F&&P.length===0&&(0,z.jsxs)(`div`,{className:`integration-empty`,children:[(0,z.jsx)(`h4`,{children:n(`integrations.empty.title`)}),(0,z.jsx)(`p`,{children:n(`integrations.empty.body`)})]}),(0,z.jsx)(`h4`,{children:n(`integrations.rollback.title`)}),M.length===0?(0,z.jsxs)(`div`,{className:`integration-empty`,children:[(0,z.jsx)(`p`,{children:n(`integrations.rollback.empty`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.rollback.emptyBody`)})]}):(0,z.jsx)(`ul`,{className:`integration-history`,children:M.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`integration-history-kind`,children:n(Km[e.kind])}),(0,z.jsx)(`span`,{className:`integration-history-client`,children:e.clientId}),(0,z.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,z.jsx)(`span`,{className:`badge badge-muted`,children:n(`integrations.action.snapshotExpired`)}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>c(e),children:e.undoable?n(`integrations.action.undo`):n(`integrations.action.restorePoint`)})]},e.opId))}),s&&(0,z.jsx)(Am,{apiBase:e,row:s,onClose:()=>c(null),onRestored:U}),d&&(0,z.jsx)(Rp,{copy:{...d.toggle===`claude-desktop`?Gm:Wm,vars:{path:d.togglePath??``}},onClose:()=>f(null),onConfirm:async()=>{await J(d,!1),f(null)}})]})}function Xm({row:e}){let t=Q(),n=e.detailKey?t(e.detailKey,e.detailVars??void 0):null;return(0,z.jsxs)(`div`,{className:`integration-api-keys-row`,"data-client":`keys`,"data-key-state":e.state,children:[(0,z.jsxs)(`div`,{className:`integration-api-keys-copy`,children:[(0,z.jsx)(`h4`,{children:t(e.labelKey)}),n&&(0,z.jsx)(`p`,{className:`integration-meta`,children:n})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>Ue(e.hash),children:t(`integrations.action.manageKeys`)})]})}var Zm={opencode:`integrations.semantics.opencode`,pi:`integrations.semantics.pi`,omp:`integrations.semantics.omp`,hermes:`integrations.semantics.hermes`,openclaw:`integrations.semantics.openclaw`,kimi:`integrations.semantics.kimi`,gajae:`integrations.semantics.gajae`},Qm={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`},$m={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`};function eh({apiBase:e,client:t,active:n=!0}){let r=Q(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),u=(0,_.useCallback)(n=>Yp(e,t,n),[e,t]),d=(0,_.useCallback)(async n=>(await Xp(e,t,n)).operations,[e,t]),f=bs(`integration-state:${e}:${t}`,[e,t],u,{isEmpty:()=>!1,enabled:n}),p=bs(`integration-journal:${e}:${t}`,[e,t],d,{isEmpty:e=>e.length===0,enabled:n}),m=f.state.data??null,h=p.state.data??[],g=()=>{f.refresh(),p.refresh()},v=async n=>{if(!(!m||i)){a(!0),s(null);try{await Zp(e,t,n),g()}catch(e){s(Sm(r,e))}finally{a(!1)}}},y=()=>void v(!(m&&(m.state===`current`||m.state===`stale`)));if(!m)return(0,z.jsx)(`section`,{className:`integration-client-page`,children:f.state.kind===`failed-cold`?(0,z.jsx)($,{tone:`err`,children:r(`integrations.error.load`)}):(0,z.jsx)(`p`,{className:`page-sub`,children:r(`common.loading`)})});let b=m.state===`current`||m.state===`stale`,x=!m.installed||m.state===`conflict`||m.state===`unsafe`;return(0,z.jsxs)(`section`,{className:`integration-client-page`,children:[(0,z.jsxs)(`div`,{className:`integration-client-head`,children:[(0,z.jsx)(`h3`,{children:r(Qm[t])}),(0,z.jsx)(km,{state:m.state,installed:m.installed,id:`integration-state-${t}`}),(0,z.jsx)(tt,{on:b,onClick:y,disabled:x||i,label:r(b?`integrations.action.disable`:`integrations.action.apply`)})]}),m.state===`stale`&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void v(!0),disabled:i,children:r(`integrations.action.refresh`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:r(Zm[t])}),(0,z.jsx)(`p`,{className:`integration-path`,children:m.configPath}),m.appliedAt&&(0,z.jsxs)(`p`,{className:`integration-meta`,children:[r(`integrations.status.appliedAt`),`: `,new Date(m.appliedAt).toLocaleString()]}),m.retentionDegraded&&(0,z.jsx)($,{tone:`err`,children:r(`integrations.retention.degraded`)}),o&&(0,z.jsx)($,{tone:`err`,children:o}),(0,z.jsx)(`h4`,{children:r(`integrations.rollback.title`)}),h.length===0?(0,z.jsx)(`p`,{className:`page-sub`,children:r(`integrations.rollback.empty`)}):(0,z.jsx)(`ul`,{className:`integration-history`,children:h.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`integration-history-kind`,children:r($m[e.kind])}),(0,z.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,z.jsx)(`span`,{className:`badge badge-muted`,children:r(`integrations.action.snapshotExpired`)}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>l(e),children:e.undoable?r(`integrations.action.undo`):r(`integrations.action.restorePoint`)})]},e.opId))}),c&&(0,z.jsx)(Am,{apiBase:e,row:c,onClose:()=>l(null),onRestored:g})]})}var th=[{id:`overview`,hash:`integrations`,labelKey:`integrations.tab.overview`},{id:`keys`,hash:`integrations/keys`,labelKey:`integrations.tab.keys`},{id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`},{id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`},{id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`},{id:`opencode`,hash:`integrations/opencode`,labelKey:`integrations.tab.opencode`},{id:`pi`,hash:`integrations/pi`,labelKey:`integrations.tab.pi`},{id:`omp`,hash:`integrations/omp`,labelKey:`integrations.tab.omp`},{id:`hermes`,hash:`integrations/hermes`,labelKey:`integrations.tab.hermes`},{id:`openclaw`,hash:`integrations/openclaw`,labelKey:`integrations.tab.openclaw`},{id:`kimi`,hash:`integrations/kimi`,labelKey:`integrations.tab.kimi`},{id:`gajae`,hash:`integrations/gajae`,labelKey:`integrations.tab.gajae`}],nh=new Set([`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`]);function rh(e=window.location.hash){let t=Ve(e);return t===`integrations/claude/desktop`?`claude`:th.find(e=>e.hash===t)?.id??`overview`}function ih(e){return`integrations-tab-${e}`}function ah(e){return`integrations-panel-${e}`}function oh({apiBase:e}){let t=Q(),[n,r]=(0,_.useState)(rh),[i,a]=(0,_.useState)(()=>new Set([rh()])),o=(0,_.useRef)(null);o.current===null&&(o.current=new Map);let s=e=>{r(e),a(t=>t.has(e)?t:new Set([...t,e]))};(0,_.useEffect)(()=>{let e=()=>s(rh());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let c=(e,t)=>{let n=th.find(t=>t.id===e);n&&(Ue(n.hash),s(e),t&&window.requestAnimationFrame(()=>{o.current.get(e)?.focus({preventScroll:!0})}))},l=e=>{let t=th.findIndex(e=>e.id===n),r=null;e.key===`ArrowLeft`?r=(t-1+th.length)%th.length:e.key===`ArrowRight`?r=(t+1)%th.length:e.key===`Home`?r=0:e.key===`End`&&(r=th.length-1),r!==null&&(e.preventDefault(),c(th[r].id,!0))};return(0,z.jsxs)(`section`,{className:`integrations-page`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`nav.integrations`)})}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`integrations.subtitle`)}),(0,z.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":t(`integrations.tabsLabel`),children:th.map(e=>(0,z.jsx)(`button`,{ref:t=>{t?o.current.set(e.id,t):o.current.delete(e.id)},type:`button`,role:`tab`,id:ih(e.id),"aria-selected":n===e.id,"aria-controls":ah(e.id),tabIndex:n===e.id?0:-1,className:`page-tab${n===e.id?` page-tab--active`:``}`,onClick:()=>c(e.id,!0),onKeyDown:l,children:t(e.labelKey)},e.id))}),th.map(t=>{if(!i.has(t.id))return null;let r=n===t.id;return(0,z.jsxs)(`div`,{role:`tabpanel`,id:ah(t.id),"aria-labelledby":ih(t.id),hidden:!r,children:[t.id===`overview`&&(0,z.jsx)(Ym,{apiBase:e,active:r}),t.id===`keys`&&(0,z.jsx)(Hf,{apiBase:e,active:r}),t.id===`codex`&&(0,z.jsx)(Em,{apiBase:e,active:r}),t.id===`claude`&&(0,z.jsx)(Ap,{apiBase:e,active:r}),t.id===`grok`&&(0,z.jsx)(Ip,{apiBase:e,active:r}),nh.has(t.id)&&(0,z.jsx)(eh,{apiBase:e,client:t.id,active:r})]},t.id)})]})}var sh=class e{static Ecc;static encodeText(t,n){let r=dh.makeSegments(t);return e.encodeSegments(r,n)}static encodeBinary(t,n){let r=dh.makeBytes(t);return e.encodeSegments([r],n)}static encodeSegments(t,n,r=1,i=40,a=-1,o=!0){if(!(e.MIN_VERSION<=r&&r<=i&&i<=e.MAX_VERSION)||a<-1||a>7)throw RangeError(`Invalid value`);let s,c;for(s=r;;s++){let r=e.getNumDataCodewords(s,n)*8,a=dh.getTotalBits(t,s);if(a<=r){c=a;break}if(s>=i)throw RangeError(`Data too long`)}for(let t of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])o&&c<=e.getNumDataCodewords(s,t)*8&&(n=t);let l=[];for(let e of t){ch(e.mode.modeBits,4,l),ch(e.numChars,e.mode.numCharCountBits(s),l);for(let t of e.getData())l.push(t)}uh(l.length==c);let u=e.getNumDataCodewords(s,n)*8;uh(l.length<=u),ch(0,Math.min(4,u-l.length),l),ch(0,(8-l.length%8)%8,l),uh(l.length%8==0);for(let e=236;l.length<u;e^=253)ch(e,8,l);let d=[];for(;d.length*8<l.length;)d.push(0);return l.forEach((e,t)=>d[t>>>3]|=e<<7-(t&7)),new e(s,n,d,a)}version;errorCorrectionLevel;size;mask;modules=[];isFunction=[];constructor(t,n,r,i){if(this.version=t,this.errorCorrectionLevel=n,t<e.MIN_VERSION||t>e.MAX_VERSION)throw RangeError(`Version value out of range`);if(i<-1||i>7)throw RangeError(`Mask value out of range`);this.size=t*4+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();let o=this.addEccAndInterleave(r);if(this.drawCodewords(o),i==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(i=t,e=n),this.applyMask(t)}}uh(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;uh(!(r>>>15));for(let e=0;e<=5;e++)this.setFunctionModule(8,e,lh(r,e));this.setFunctionModule(8,7,lh(r,6)),this.setFunctionModule(8,8,lh(r,7)),this.setFunctionModule(7,8,lh(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,lh(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,lh(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,lh(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;uh(!(t>>>18));for(let e=0;e<18;e++){let n=lh(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(t){let n=this.version,r=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let i=e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],a=e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],o=Math.floor(e.getNumRawDataModules(n)/8),s=i-o%i,c=Math.floor(o/i),l=[],u=e.reedSolomonComputeDivisor(a);for(let n=0,r=0;n<i;n++){let i=t.slice(r,r+c-a+(n<s?0:1));r+=i.length;let o=e.reedSolomonComputeRemainder(i,u);n<s&&i.push(0),l.push(i.concat(o))}let d=[];for(let e=0;e<l[0].length;e++)l.forEach((t,n)=>{(e!=c-a||n>=s)&&d.push(t[e])});return uh(d.length==o),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let e=this.size-1;e>=1;e-=2){e==6&&(e=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=e-i,o=e+1&2?r:this.size-1-r;!this.isFunction[o][a]&&n<t.length*8&&(this.modules[o][a]=lh(t[n>>>3],7-(n&7)),n++)}}uh(n==t.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let t=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]===r?(i++,i==5?t+=e.PENALTY_N1:i>5&&t++):(this.finderPenaltyAddHistory(i,a),r||(t+=this.finderPenaltyCountPatterns(a)*e.PENALTY_N3),r=this.modules[n][o],i=1);t+=this.finderPenaltyTerminateAndCount(r,i,a)*e.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]===r?(i++,i==5?t+=e.PENALTY_N1:i>5&&t++):(this.finderPenaltyAddHistory(i,a),r||(t+=this.finderPenaltyCountPatterns(a)*e.PENALTY_N3),r=this.modules[o][n],i=1);t+=this.finderPenaltyTerminateAndCount(r,i,a)*e.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(t+=e.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,i=Math.ceil(Math.abs(n*20-r*10)/r)-1;return uh(0<=i&&i<=9),t+=i*e.PENALTY_N4,uh(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*t+128)*t+64;if(t>=2){let e=Math.floor(t/7)+2;n-=(25*e-10)*e-55,t>=7&&(n-=36)}return uh(208<=n&&n<=29648),n}static getNumDataCodewords(t,n){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw RangeError(`Degree out of range`);let n=[];for(let e=0;e<t-1;e++)n.push(0);n.push(1);let r=1;for(let i=0;i<t;i++){for(let t=0;t<n.length;t++)n[t]=e.reedSolomonMultiply(n[t],r),t+1<n.length&&(n[t]^=n[t+1]);r=e.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(t,n){let r=n.map(e=>0);for(let i of t){let t=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=e.reedSolomonMultiply(n,t))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return uh(!(n>>>8)),n}finderPenaltyCountPatterns(e){let t=e[1];uh(t<=this.size*3);let n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}static MIN_VERSION=1;static MAX_VERSION=40;static PENALTY_N1=3;static PENALTY_N2=3;static PENALTY_N3=40;static PENALTY_N4=10;static ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]];static NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]]};function ch(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function lh(e,t){return!!(e>>>t&1)}function uh(e){if(!e)throw Error(`Assertion error`)}var dh=class e{static Mode;static makeBytes(t){let n=[];for(let e of t)ch(e,8,n);return new e(e.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let n=[];for(let e=0;e<t.length;){let r=Math.min(t.length-e,3);ch(parseInt(t.substring(e,e+r),10),r*3+1,n),e+=r}return new e(e.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let n=[],r;for(r=0;r+2<=t.length;r+=2){let i=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r))*45;i+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r+1)),ch(i,11,n)}return r<t.length&&ch(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r)),6,n),new e(e.Mode.ALPHANUMERIC,t.length,n)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let n=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)ch(t,8,n);else if(t<16384)ch(2,2,n),ch(t,14,n);else if(t<1e6)ch(6,3,n),ch(t,21,n);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,n)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}mode;numChars;bitData;constructor(e,t,n){if(this.mode=e,this.numChars=t,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}static NUMERIC_REGEX=/^[0-9]*$/;static ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/;static ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`},fh=class e{static LOW=new e(0,1);static MEDIUM=new e(1,0);static QUARTILE=new e(2,3);static HIGH=new e(3,2);ordinal;formatBits;constructor(e,t){this.ordinal=e,this.formatBits=t}},ph=class e{static NUMERIC=new e(1,[10,12,14]);static ALPHANUMERIC=new e(2,[9,11,13]);static BYTE=new e(4,[8,16,16]);static KANJI=new e(8,[8,10,12]);static ECI=new e(7,[0,0,0]);modeBits;numBitsCharCount;constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};sh.Ecc=fh,dh.Mode=ph;function mh(e,t){let n=[];for(let r=0;r<e.size;r+=1){let i=-1;for(let a=0;a<=e.size;a+=1){if(a<e.size&&e.getModule(a,r)){i===-1&&(i=a);continue}i!==-1&&(n.push(`M${i+t} ${r+t}h${a-i}v1H${i+t}z`),i=-1)}}return n.join(``)}var hh=(0,_.memo)(function({value:e,size:t=220,title:n,className:r}){let i=sh.encodeText(e,sh.Ecc.MEDIUM),a=i.size+8;return(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 ${a} ${a}`,width:t,height:t,shapeRendering:`crispEdges`,role:`img`,"aria-label":n,className:r,children:[n?(0,z.jsx)(`title`,{children:n}):null,(0,z.jsx)(`rect`,{width:a,height:a,fill:`#fff`}),(0,z.jsx)(`path`,{d:mh(i,4),fill:`#111`})]})}),gh=new Set([`dashboard`,`startup`,`providers`,`models`,`subagents`,`logs`,`desktop-logs`,`usage`,`storage`,`codex-auth`,`integrations`,`android-remote`,`guide`]),_h=`android-remote/pair`;function vh(e){let t=Ve(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:t===`combos`||t===`routing`?`models`:t===`api`||t===`claude`||t===`grok`?`integrations`:gh.has(t)?t:`dashboard`}var yh=[`dashboard/providers`,`dashboard/models`],bh=[`models/combos`,`models/routing`],xh=[`integrations/keys`,`integrations/codex`,`integrations/claude`,`integrations/claude/desktop`,`integrations/grok`,`integrations/opencode`,`integrations/pi`,`integrations/omp`,`integrations/hermes`,`integrations/openclaw`,`integrations/kimi`,`integrations/gajae`];function Sh(e,t){return e===t||t===`android-remote`&&e===`android-remote/pair`||t===`logs`&&e===`logs/debug`||t===`models`&&bh.includes(e)||t===`dashboard`&&(e===`dashboard/update`||yh.includes(e))||t===`integrations`&&xh.includes(e)}function Ch(e){let t=vh(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`combos`||e.startsWith(`combos/`)?{page:`models`,replaceTo:`models/combos`}:e===`routing`||e.startsWith(`routing/`)?{page:`models`,replaceTo:`models/routing`}:e===`api`?{page:`integrations`,replaceTo:`integrations/keys`}:e===`claude`?{page:`integrations`,replaceTo:`integrations/claude`}:e===`grok`?{page:`integrations`,replaceTo:`integrations/grok`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:Sh(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}function wh(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Th(e){return e===void 0||typeof e==`string`}function Eh(e){return wh(e)?typeof e.id==`string`&&typeof e.label==`string`&&e.deviceType===`mobile`&&typeof e.os==`string`&&Th(e.address)&&Array.isArray(e.scopes)&&e.scopes.every(e=>typeof e==`string`)&&typeof e.createdAt==`string`&&Th(e.lastSeenAt)&&typeof e.online==`boolean`:!1}function Dh(e){return!wh(e)||!wh(e.configuration)||!wh(e.runtime)?!1:[`quick`,`named`].includes(String(e.configuration.mode))&&Th(e.configuration.namedHostname)&&typeof e.configuration.hasNamedTunnelToken==`boolean`&&[`quick`,`named`].includes(String(e.runtime.mode))&&[`stopped`,`starting`,`checking`,`ready`,`error`].includes(String(e.runtime.status))&&(e.runtime.publicUrl===null||typeof e.runtime.publicUrl==`string`)&&(e.runtime.error===null||[`cloudflared_unavailable`,`named_tunnel_incomplete`,`tunnel_failed`,`verification_failed`].includes(String(e.runtime.error)))}function Oh(e){return!wh(e)||!wh(e.gateway)||!wh(e.desktop)?!1:e.version===1&&typeof e.controlEnabled==`boolean`&&typeof e.keepAwake==`boolean`&&typeof e.pairingAvailable==`boolean`&&[`stopped`,`starting`,`ready`,`error`].includes(String(e.gateway.status))&&e.gateway.backgroundServer===`current-process`&&typeof e.gateway.port==`number`&&Number.isInteger(e.gateway.port)&&Th(e.gateway.error)&&Array.isArray(e.reachableAddresses)&&e.reachableAddresses.every(e=>typeof e==`string`)&&Dh(e.tunnel)&&e.desktop.id===`desktop`&&typeof e.desktop.label==`string`&&typeof e.desktop.platform==`string`&&typeof e.desktop.address==`string`&&e.desktop.online===!0&&Array.isArray(e.clients)&&e.clients.every(Eh)}function kh(e){return wh(e)&&e.version===1&&typeof e.id==`string`&&typeof e.expiresAt==`string`&&Number.isFinite(Date.parse(e.expiresAt))&&typeof e.qrPayload==`string`&&e.qrPayload.length>0}function Ah(e){return wh(e)&&typeof e.id==`string`&&typeof e.name==`string`}function jh(e){return wh(e)&&typeof e.id==`string`&&typeof e.name==`string`&&typeof e.accountId==`string`&&typeof e.accountName==`string`&&[`active`,`pending`,`initializing`,`moved`,`deactivated`,`unknown`].includes(String(e.status))&&Array.isArray(e.nameServers)&&e.nameServers.every(e=>typeof e==`string`)}function Mh(e){return wh(e)&&e.version===1&&Array.isArray(e.accounts)&&e.accounts.every(Ah)&&Array.isArray(e.zones)&&e.zones.every(jh)}async function Nh(e){let t=await ct(e);if(!Oh(t))throw Error(`invalid Android Remote response`);return t}function Ph(e){return`android-remote:${e}`}async function Fh(e,t){return Nh(await fetch(`${e}/api/android-remote`,{signal:t}))}async function Ih(e,t){return Nh(await fetch(`${e}/api/android-remote/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}))}async function Lh(e,t){return Nh(await fetch(`${e}/api/android-remote/tunnel`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}))}async function Rh(e,t){let n=await ct(await fetch(`${e}/api/android-remote/cloudflare/discover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({apiToken:t})}));if(!Mh(n))throw Error(`invalid Cloudflare discovery response`);return n}async function zh(e,t){return Nh(await fetch(`${e}/api/android-remote/cloudflare/provision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}))}async function Bh(e){return Nh(await fetch(`${e}/api/android-remote/tunnel/retry`,{method:`POST`}))}async function Vh(e){return Nh(await fetch(`${e}/api/android-remote/tunnel/token`,{method:`DELETE`}))}async function Hh(e){return Nh(await fetch(`${e}/api/android-remote/tunnel/domain`,{method:`DELETE`}))}async function Uh(e,t){return Nh(await fetch(`${e}/api/android-remote/clients/${encodeURIComponent(t)}`,{method:`DELETE`}))}async function Wh(e){let t=await ct(await fetch(`${e}/api/android-remote/pairing`,{method:`POST`}));if(!kh(t))throw Error(`invalid Android Remote pairing response`);return t}function Gh(e=globalThis.crypto){let t=e.getRandomValues(new Uint8Array(5));return`rmx-${Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}`}function Kh({apiBase:e,status:t,onClose:n}){let r=(0,_.useRef)(null),{t:i}=Z(),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(0),p=(0,_.useCallback)(async()=>{if(t.pairingAvailable){c(!0),u(!1),o(null),f(Date.now());try{let t=await Wh(e);o(t),f(Date.now())}catch{o(null),u(!0)}finally{c(!1)}}},[e,t.pairingAvailable]);(0,_.useEffect)(()=>{let e=r.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]),(0,_.useEffect)(()=>{let e=window.setTimeout(()=>void p(),0);return()=>window.clearTimeout(e)},[p]),(0,_.useEffect)(()=>{if(!a)return;let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[a]);let m=a?Math.max(0,Math.ceil((Date.parse(a.expiresAt)-d)/1e3)):0,h=!!a&&m===0,g=`${Math.floor(m/60)}:${String(m%60).padStart(2,`0`)}`;return(0,z.jsxs)(`dialog`,{ref:r,className:`modal-overlay`,"aria-labelledby":`android-remote-pairing-title`,"aria-describedby":`android-remote-pairing-desc`,onCancel:e=>{e.preventDefault(),n()},children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":i(`common.close`),tabIndex:-1,onClick:n}),(0,z.jsxs)(`div`,{className:`modal-card android-remote-dialog`,role:`document`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsxs)(`div`,{className:`android-remote-dialog-title`,children:[(0,z.jsx)(`span`,{className:`android-remote-dialog-icon`,"aria-hidden":`true`,children:(0,z.jsx)(Ce,{})}),(0,z.jsx)(`h3`,{id:`android-remote-pairing-title`,children:i(`remote.dialog.title`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon`,onClick:n,"aria-label":i(`common.close`),children:(0,z.jsx)(Y,{})})]}),(0,z.jsx)(`p`,{id:`android-remote-pairing-desc`,className:`modal-desc`,children:i(`remote.dialog.description`)}),!t.pairingAvailable&&(0,z.jsxs)(`div`,{className:`android-remote-readiness`,role:`status`,children:[(0,z.jsxs)(`div`,{className:`android-remote-readiness-row ready`,children:[(0,z.jsx)(J,{"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.dialog.dashboardReady`)}),(0,z.jsx)(`span`,{children:i(`remote.dialog.dashboardReadyHint`)})]})]}),(0,z.jsxs)(`div`,{className:`android-remote-readiness-row pending`,children:[(0,z.jsx)(he,{"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(t.gateway.status===`error`?`remote.dialog.gatewayError`:`remote.dialog.gatewayPending`)}),(0,z.jsx)(`span`,{children:i(t.gateway.status===`starting`?`remote.dialog.gatewayStartingHint`:t.gateway.status===`error`?`remote.dialog.gatewayErrorHint`:`remote.dialog.gatewayPendingHint`)})]})]}),(0,z.jsxs)(`div`,{className:`android-remote-readiness-row pending`,children:[(0,z.jsx)(Ce,{"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.dialog.enableControl`)}),(0,z.jsx)(`span`,{children:i(`remote.dialog.enableControlHint`)})]})]})]}),t.pairingAvailable&&s&&!a&&(0,z.jsxs)(`div`,{className:`android-remote-pairing-state`,role:`status`,children:[(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:i(`remote.dialog.creatingCode`)})]}),t.pairingAvailable&&l&&!s&&(0,z.jsxs)(`div`,{className:`android-remote-pairing-failure`,children:[(0,z.jsx)($,{tone:`err`,children:i(`remote.dialog.codeError`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void p(),children:[(0,z.jsx)(X,{}),` `,i(`common.retry`)]})]}),t.pairingAvailable&&a&&!h&&(0,z.jsxs)(`div`,{className:`android-remote-pairing`,children:[(0,z.jsx)(`div`,{className:`android-remote-qr-frame`,children:(0,z.jsx)(hh,{value:a.qrPayload,title:i(`remote.dialog.qrTitle`)})}),(0,z.jsxs)(`div`,{className:`android-remote-pairing-copy`,children:[(0,z.jsx)(`strong`,{children:i(`remote.dialog.scanTitle`)}),(0,z.jsx)(`span`,{children:i(`remote.dialog.scanHint`)}),(0,z.jsxs)(`div`,{className:`android-remote-pairing-meta`,children:[(0,z.jsx)(`span`,{className:`android-remote-pairing-expiry`,role:`timer`,children:i(`remote.dialog.expiresIn`,{value:g})}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void p(),disabled:s,"aria-label":i(`remote.dialog.refreshCode`),children:[(0,z.jsx)(X,{"aria-hidden":`true`}),` `,i(`remote.dialog.refreshCode`)]})]})]})]}),t.pairingAvailable&&a&&h&&(0,z.jsxs)(`div`,{className:`android-remote-pairing-failure`,children:[(0,z.jsx)($,{tone:`warn`,children:i(`remote.dialog.codeExpired`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void p(),children:[(0,z.jsx)(X,{}),` `,i(`remote.dialog.newCode`)]})]}),(0,z.jsx)(`div`,{className:`modal-actions android-remote-dialog-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:n,children:i(`common.close`)})})]})]})}function qh(e,t){return t(e===`ready`?`remote.gatewayReady`:e===`starting`?`remote.gatewayStarting`:e===`error`?`remote.gatewayError`:`remote.gatewayStopped`)}function Jh(e,t){return t(e===`ready`?`remote.tunnel.statusReady`:e===`starting`?`remote.tunnel.statusStarting`:e===`checking`?`remote.tunnel.statusChecking`:e===`error`?`remote.tunnel.statusFailed`:`remote.tunnel.statusStopped`)}function Yh({state:e,children:t}){return(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-progress-row ${e}`,"aria-current":e===`active`?`step`:void 0,children:[e===`complete`&&(0,z.jsx)(J,{"aria-hidden":`true`}),e===`active`&&(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}),e===`failed`&&(0,z.jsx)(Y,{"aria-hidden":`true`}),e===`pending`&&(0,z.jsx)(`span`,{className:`android-remote-progress-dot`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t})]})}function Xh({apiBase:e,status:t,onPublish:n,onError:r}){let{t:i}=Z(),[a,o]=(0,_.useState)(t.tunnel.configuration.mode),[s,c]=(0,_.useState)(t.tunnel.configuration.namedHostname??``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(Gh),[S,C]=(0,_.useState)(!0),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(null),A=(0,_.useRef)(null),j=`${t.tunnel.configuration.mode}:${t.tunnel.configuration.namedHostname??``}`,M=(0,_.useRef)(j);(0,_.useEffect)(()=>{M.current!==j&&(M.current=j,o(t.tunnel.configuration.mode),c(t.tunnel.configuration.namedHostname??``))},[j,t.tunnel.configuration.mode,t.tunnel.configuration.namedHostname]);let N=e=>{T(e instanceof Error?e.message:i(`remote.tunnel.automaticError`))},P=async()=>{o(`quick`),k(`quick`),T(null);try{n(await Lh(e,{mode:`quick`}))}catch(e){o(t.tunnel.configuration.mode),N(e)}finally{k(null)}},F=async()=>{k(`manual`),T(null);try{let t=await Lh(e,{mode:`named`,hostname:s,...l.trim()?{token:l.trim()}:{}});u(``),n(t)}catch(e){N(e)}finally{k(null)}},I=async()=>{k(`discover`),T(null),D(!1);try{let t=await Rh(e,d.trim());m(t);let n=t.accounts[0]?.id??``;g(n),y(t.zones.find(e=>e.accountId===n)?.id??``)}catch(e){m(null),g(``),y(``),N(e)}finally{k(null)}},L=p?.zones.filter(e=>e.accountId===h)??[],R=L.find(e=>e.id===v)??null,B=async()=>{if(R){k(`provision`),T(null),D(!1);try{let t=await zh(e,{apiToken:d.trim(),accountId:h,zoneId:R.id,hostname:`${b.trim().toLowerCase()}.${R.name}`});f(``),m(null),D(!0),n(t)}catch(e){N(e)}finally{k(null)}}},V=async()=>{k(`retry`);try{n(await Bh(e))}catch{r()}finally{k(null)}},H=async()=>{k(`remove`);try{u(``),n(await Vh(e))}catch{r()}finally{k(null)}},U=()=>{f(``),m(null),g(``),y(``),D(!1),x(Gh()),T(null),C(!1),window.setTimeout(()=>A.current?.focus(),0)},W=async()=>{k(`disconnect`),T(null);try{let t=await Hh(e);f(``),m(null),g(``),y(``),D(!1),c(``),o(`quick`),n(t)}catch(e){N(e)}finally{k(null)}},G=t.tunnel.runtime,ee=G.status===`checking`||G.status===`ready`||G.status===`error`&&G.error===`verification_failed`?`complete`:G.status===`starting`?`active`:G.status===`error`?`failed`:`pending`,te=G.status===`ready`?`complete`:G.status===`checking`?`active`:G.status===`error`&&G.error===`verification_failed`?`failed`:`pending`,K=G.error===`cloudflared_unavailable`?`remote.tunnel.errorCloudflared`:G.error===`named_tunnel_incomplete`?`remote.tunnel.errorIncomplete`:G.error===`verification_failed`?`remote.tunnel.errorVerification`:`remote.tunnel.errorFailed`;return(0,z.jsxs)(`section`,{className:`android-remote-section`,"aria-labelledby":`android-remote-tunnel-heading`,children:[(0,z.jsxs)(`div`,{className:`android-remote-section-heading`,children:[(0,z.jsx)(Se,{"aria-hidden":`true`}),(0,z.jsx)(`h3`,{id:`android-remote-tunnel-heading`,children:i(`remote.tunnel.heading`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-card`,children:[(0,z.jsxs)(`div`,{className:`android-remote-tunnel-intro`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.title`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.hint`)})]}),(0,z.jsx)(`span`,{className:`android-remote-gateway-badge ${G.status}`,role:`status`,children:Jh(G.status,i)})]}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-options`,role:`radiogroup`,"aria-label":i(`remote.tunnel.modeLabel`),children:[(0,z.jsxs)(`label`,{className:`android-remote-tunnel-option ${a===`quick`?`selected`:``}`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`android-tunnel-mode`,value:`quick`,checked:a===`quick`,disabled:O!==null,onChange:()=>{t.tunnel.configuration.mode===`quick`?o(`quick`):P()}}),(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`span`,{className:`android-remote-tunnel-option-title`,children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.quickTitle`)}),(0,z.jsx)(`em`,{children:i(`remote.tunnel.quickBadge`)})]}),(0,z.jsx)(`small`,{children:i(`remote.tunnel.quickHint`)})]})]}),(0,z.jsxs)(`label`,{className:`android-remote-tunnel-option ${a===`named`?`selected`:``}`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`android-tunnel-mode`,value:`named`,checked:a===`named`,disabled:O!==null,onChange:()=>o(`named`)}),(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`span`,{className:`android-remote-tunnel-option-title`,children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.namedTitle`)}),(0,z.jsx)(`em`,{children:i(`remote.tunnel.namedBadge`)})]}),(0,z.jsx)(`small`,{children:i(`remote.tunnel.namedHint`)})]})]})]}),(0,z.jsxs)(`details`,{className:`android-remote-tunnel-compare`,children:[(0,z.jsx)(`summary`,{children:i(`remote.tunnel.compareTitle`)}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-compare-grid`,children:[(0,z.jsxs)(`article`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.quickTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.compareQuickBest`)}),(0,z.jsxs)(`ul`,{children:[(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareQuickSetup`)}),(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareQuickAddress`)}),(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareQuickLimit`)})]})]}),(0,z.jsxs)(`article`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.namedTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.compareNamedBest`)}),(0,z.jsxs)(`ul`,{children:[(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareNamedAddress`)}),(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareNamedSetup`)}),(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareNamedTime`)})]})]})]}),(0,z.jsx)(`p`,{className:`android-remote-tunnel-compare-shared`,children:i(`remote.tunnel.compareShared`)})]}),a===`named`&&(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-wizard`,children:[(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-wizard-copy`,children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.automaticTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.automaticHint`)})]}),(0,z.jsxs)(`details`,{className:`android-remote-cloudflare-token-guide`,open:S,onToggle:e=>C(e.currentTarget.open),children:[(0,z.jsx)(`summary`,{children:(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenGuideTitle`)}),(0,z.jsx)(`small`,{children:i(`remote.tunnel.tokenGuideHint`)})]})}),(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-token-guide-body`,children:[(0,z.jsx)(`a`,{className:`btn btn-ghost`,href:`https://dash.cloudflare.com/profile/api-tokens`,target:`_blank`,rel:`noreferrer`,children:i(`remote.tunnel.createApiToken`)}),(0,z.jsxs)(`ol`,{children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenStepCustomTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.tokenStepCustomBody`)})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenStepPermissionsTitle`)}),(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-permission-list`,role:`list`,children:[(0,z.jsx)(`code`,{role:`listitem`,children:i(`remote.tunnel.tokenPermissionTunnel`)}),(0,z.jsx)(`code`,{role:`listitem`,children:i(`remote.tunnel.tokenPermissionDns`)}),(0,z.jsx)(`code`,{role:`listitem`,children:i(`remote.tunnel.tokenPermissionZone`)})]})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenStepResourcesTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.tokenStepResourcesBody`)})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenStepCopyTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.tokenStepCopyBody`)})]})})]}),(0,z.jsx)(`p`,{className:`android-remote-cloudflare-token-guide-finish`,children:i(`remote.tunnel.tokenGuideFinish`)})]})]}),(0,z.jsxs)(`label`,{className:`android-remote-cloudflare-field`,children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.apiTokenLabel`)}),(0,z.jsx)(`input`,{ref:A,type:`password`,value:d,onChange:e=>{f(e.target.value),m(null),g(``),y(``),D(!1)},placeholder:i(`remote.tunnel.apiTokenPlaceholder`),autoComplete:`off`,spellCheck:!1})]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost android-remote-cloudflare-authorize`,disabled:O!==null||!d.trim(),onClick:()=>void I(),children:[O===`discover`?(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}):(0,z.jsx)(Se,{"aria-hidden":`true`}),i(O===`discover`?`remote.tunnel.authorizing`:p?`remote.tunnel.refreshDomains`:`remote.tunnel.authorize`)]}),p&&(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-selection`,children:[(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-progress-row complete`,children:[(0,z.jsx)(J,{"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:i(`remote.tunnel.authorized`)})]}),p.accounts.length===0||p.zones.length===0?(0,z.jsx)($,{tone:`warn`,children:i(`remote.tunnel.noDomains`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`android-remote-tunnel-form`,children:[(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.accountLabel`)}),(0,z.jsx)(`select`,{value:h,onChange:e=>{let t=e.target.value;g(t),y(p.zones.find(e=>e.accountId===t)?.id??``)},children:p.accounts.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.domainLabel`)}),(0,z.jsx)(`select`,{value:v,onChange:e=>y(e.target.value),children:L.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}),R&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`android-remote-cloudflare-field`,children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.subdomainLabel`)}),(0,z.jsxs)(`div`,{className:`android-remote-subdomain-input`,children:[(0,z.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1}),(0,z.jsxs)(`span`,{children:[`.`,R.name]})]}),(0,z.jsx)(`small`,{children:i(`remote.tunnel.subdomainSecurityHint`)})]}),R.status!==`active`&&(0,z.jsxs)($,{tone:`warn`,children:[i(`remote.tunnel.domainPending`),R.nameServers.length>0&&(0,z.jsx)(`span`,{className:`android-remote-name-servers`,children:R.nameServers.map(e=>(0,z.jsx)(`code`,{children:e},e))})]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary android-remote-cloudflare-connect`,disabled:O!==null||R.status!==`active`||!b.trim(),onClick:()=>void B(),children:[O===`provision`?(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}):(0,z.jsx)(J,{"aria-hidden":`true`}),i(O===`provision`?`remote.tunnel.connecting`:`remote.tunnel.connect`)]})]})]})]}),E&&(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-progress`,"aria-label":i(`remote.tunnel.progressLabel`),"aria-live":`polite`,children:[(0,z.jsx)(Yh,{state:`complete`,children:i(`remote.tunnel.resourcesConfigured`)}),(0,z.jsx)(Yh,{state:ee,children:i(`remote.tunnel.connectorAccepted`)}),(0,z.jsx)(Yh,{state:te,children:i(`remote.tunnel.gatewayVerified`)})]}),(0,z.jsxs)(`details`,{className:`android-remote-tunnel-guide android-remote-manual-setup`,children:[(0,z.jsx)(`summary`,{children:i(`remote.tunnel.manualTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.manualHint`)}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-form`,children:[(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.hostnameLabel`)}),(0,z.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`codex.example.com`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.tokenLabel`)}),(0,z.jsx)(`input`,{type:`password`,value:l,onChange:e=>u(e.target.value),placeholder:t.tunnel.configuration.hasNamedTunnelToken?i(`remote.tunnel.tokenSavedPlaceholder`):i(`remote.tunnel.tokenPlaceholder`),autoComplete:`off`})]})]}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:O!==null||!s.trim(),onClick:()=>void F(),children:i(O===`manual`?`remote.tunnel.saving`:`remote.tunnel.manualSave`)}),t.tunnel.configuration.hasNamedTunnelToken&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:O!==null,onClick:()=>void H(),children:i(`remote.tunnel.removeToken`)})]}),(0,z.jsx)(`p`,{className:`android-remote-tunnel-guide-note`,children:i(`remote.tunnel.manualOrigin`)})]})]}),G.mode===a&&G.status===`ready`&&G.publicUrl&&(0,z.jsxs)(`div`,{className:`android-remote-tunnel-url`,children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.verifiedUrl`)}),(0,z.jsx)(`code`,{children:G.publicUrl})]}),t.tunnel.configuration.mode===`named`&&t.tunnel.configuration.namedHostname&&(0,z.jsxs)(`div`,{className:`android-remote-domain-management`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.domainManagementTitle`)}),(0,z.jsx)(`code`,{children:t.tunnel.configuration.namedHostname}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.domainManagementHint`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-domain-management-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:O!==null,onClick:U,children:i(`remote.tunnel.changeDomain`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-danger`,disabled:O!==null,onClick:()=>void W(),children:[O===`disconnect`?(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}):(0,z.jsx)(Y,{"aria-hidden":`true`}),i(O===`disconnect`?`remote.tunnel.disconnectingDomain`:`remote.tunnel.disconnectDomain`)]})]})]}),w&&(0,z.jsx)($,{tone:`err`,children:w}),G.status===`error`&&G.error&&(0,z.jsx)($,{tone:`err`,children:i(K)}),(0,z.jsx)(`div`,{className:`android-remote-tunnel-actions`,children:(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:O!==null||!t.controlEnabled,onClick:()=>void V(),children:[(0,z.jsx)(X,{}),` `,i(O===`retry`?`remote.tunnel.retrying`:`common.retry`)]})})]})]})}function Zh({client:e,busy:t,onRevoke:n}){let{t:r,locale:i}=Z(),a=e.lastSeenAt?new Date(e.lastSeenAt).toLocaleString(i):r(`remote.neverSeen`);return(0,z.jsxs)(`div`,{className:`android-remote-client-row`,children:[(0,z.jsxs)(`div`,{className:`android-remote-client-main`,children:[(0,z.jsx)(`span`,{className:`android-remote-status-dot ${e.online?`online`:`offline`}`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`android-remote-client-copy`,children:[(0,z.jsxs)(`div`,{className:`android-remote-client-name`,children:[(0,z.jsx)(`strong`,{children:e.label}),(0,z.jsx)(`span`,{className:`android-remote-state-label`,children:r(e.online?`remote.online`:`remote.offline`)})]}),(0,z.jsx)(`span`,{children:r(`remote.mobileMeta`,{os:e.os,address:e.address??r(`remote.unknownAddress`),count:e.scopes.length})}),(0,z.jsx)(`span`,{children:r(`remote.lastSeen`,{value:a})}),e.scopes.length>0&&(0,z.jsx)(`div`,{className:`android-remote-scopes`,"aria-label":r(`remote.permissions`),children:e.scopes.map(e=>(0,z.jsx)(`code`,{children:e},e))})]})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:n,disabled:t,children:r(t?`remote.revoking`:`remote.revoke`)})]})}function Qh({apiBase:e}){let{t}=Z(),n=Ph(e),r=bs(n,[e],t=>Fh(e,t),{isEmpty:()=>!1,pollMs:5e3}),{state:i}=r,a=i.data,[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(()=>Ve(window.location.hash)===_h),m=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=()=>{Ve(window.location.hash)===`android-remote/pair`&&p(!0)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let h=e=>{L(n,e),d(!1)},g=async(t,n)=>{s(t),d(!1);try{h(await Ih(e,{[t]:n}))}catch{d(!0)}finally{s(null)}},v=async n=>{if(window.confirm(t(`remote.revokeConfirm`,{name:n.label}))){l(n.id),d(!1);try{h(await Uh(e,n.id))}catch{d(!0)}finally{l(null)}}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head android-remote-page-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{children:t(`remote.title`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`remote.subtitle`)})]}),(0,z.jsxs)(`button`,{ref:m,type:`button`,className:`btn btn-primary android-remote-add`,onClick:()=>p(!0),"aria-haspopup":`dialog`,children:[(0,z.jsx)(ne,{}),` `,t(`remote.addPhone`)]})]}),i.showSkeleton&&!a?(0,z.jsx)(Ss,{label:t(`remote.loading`),rows:5}):i.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`android-remote-error`,children:[(0,z.jsx)($,{tone:`err`,children:t(`remote.loadError`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>r.refresh(),children:t(`common.retry`)})]}):a?(0,z.jsxs)(`div`,{className:`android-remote-page`,"aria-busy":o!==null||c!==null||void 0,children:[i.refreshing&&(0,z.jsx)(Cs,{className:`android-remote-refresh-status`,live:!i.showError,children:t(`remote.refreshing`)}),i.showError&&(0,z.jsx)($,{tone:`err`,children:t(`remote.staleError`)}),u&&(0,z.jsx)($,{tone:`err`,children:t(`remote.saveError`)}),(0,z.jsxs)(`section`,{className:`android-remote-section`,"aria-labelledby":`android-remote-settings-heading`,children:[(0,z.jsxs)(`div`,{className:`android-remote-section-heading`,children:[(0,z.jsx)(Ce,{"aria-hidden":`true`}),(0,z.jsx)(`h3`,{id:`android-remote-settings-heading`,children:t(`remote.settingsHeading`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-settings-card`,children:[(0,z.jsxs)(`div`,{className:`android-remote-setting-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:t(`remote.controlTitle`)}),(0,z.jsx)(`p`,{children:t(`remote.controlHint`)}),(0,z.jsx)(`div`,{className:`android-remote-addresses`,children:a.reachableAddresses.map(e=>(0,z.jsx)(`code`,{children:e},e))})]}),(0,z.jsx)(tt,{on:a.controlEnabled,onClick:()=>void g(`controlEnabled`,!a.controlEnabled),disabled:o!==null,label:t(`remote.controlTitle`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-setting-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:t(`remote.keepAwakeTitle`)}),(0,z.jsx)(`p`,{children:t(`remote.keepAwakeHint`)})]}),(0,z.jsx)(tt,{on:a.keepAwake,onClick:()=>void g(`keepAwake`,!a.keepAwake),disabled:o!==null||!a.controlEnabled,label:t(`remote.keepAwakeTitle`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-setting-row android-remote-gateway-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:t(`remote.backgroundTitle`)}),(0,z.jsx)(`p`,{children:t(`remote.backgroundHint`)})]}),(0,z.jsx)(`span`,{className:`android-remote-gateway-badge ${a.gateway.status}`,children:qh(a.gateway.status,t)})]})]})]}),(0,z.jsx)(Xh,{apiBase:e,status:a,onPublish:h,onError:()=>d(!0)}),(0,z.jsxs)(`section`,{className:`android-remote-section`,"aria-labelledby":`android-remote-clients-heading`,children:[(0,z.jsxs)(`div`,{className:`android-remote-section-heading`,children:[(0,z.jsx)(he,{"aria-hidden":`true`}),(0,z.jsx)(`h3`,{id:`android-remote-clients-heading`,children:t(`remote.clientsHeading`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-clients-card`,children:[(0,z.jsx)(`div`,{className:`android-remote-client-row desktop`,children:(0,z.jsxs)(`div`,{className:`android-remote-client-main`,children:[(0,z.jsx)(`span`,{className:`android-remote-status-dot online`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`android-remote-client-copy`,children:[(0,z.jsxs)(`div`,{className:`android-remote-client-name`,children:[(0,z.jsx)(`strong`,{children:a.desktop.label}),(0,z.jsx)(`span`,{className:`android-remote-this-device`,children:t(`remote.thisDevice`)})]}),(0,z.jsx)(`span`,{children:t(`remote.desktopMeta`,{platform:a.desktop.platform,address:a.desktop.address})})]})]})}),a.clients.map(e=>(0,z.jsx)(Zh,{client:e,busy:c===e.id,onRevoke:()=>void v(e)},e.id)),a.clients.length===0&&(0,z.jsxs)(`div`,{className:`android-remote-empty-clients`,children:[(0,z.jsx)(Ce,{"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:t(`remote.noPhones`)}),(0,z.jsx)(`span`,{children:t(`remote.noPhonesHint`)})]})]})]})]})]}):null,f&&a&&(0,z.jsx)(Kh,{apiBase:e,status:a,onClose:()=>{p(!1),Ve(window.location.hash)===`android-remote/pair`&&He(`android-remote`),window.setTimeout(()=>m.current?.focus(),0)}})]})}var $h=`ocx-guide-audience`;function eg(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function tg(e=eg()){try{return e?.getItem(`ocx-guide-audience`)===`advanced`?`advanced`:`beginner`}catch{return`beginner`}}function ng(e,t=eg()){try{t?.setItem($h,e)}catch{}}var rg=[{id:`dashboard`,labelKey:`nav.dashboard`,beginnerKey:`guide.section.dashboard.beginner`,advancedKey:`guide.section.dashboard.advanced`,includesKey:`guide.section.dashboard.includes`,target:`dashboard`,Icon:V},{id:`codex-auth`,labelKey:`nav.codexAuth`,beginnerKey:`guide.section.codexAuth.beginner`,advancedKey:`guide.section.codexAuth.advanced`,includesKey:`guide.section.codexAuth.includes`,target:`codex-auth`,Icon:he},{id:`providers`,labelKey:`nav.providers`,beginnerKey:`guide.section.providers.beginner`,advancedKey:`guide.section.providers.advanced`,includesKey:`guide.section.providers.includes`,target:`providers`,Icon:H},{id:`models`,labelKey:`nav.models`,beginnerKey:`guide.section.models.beginner`,advancedKey:`guide.section.models.advanced`,includesKey:`guide.section.models.includes`,target:`models`,Icon:U},{id:`subagents`,labelKey:`nav.subagents`,beginnerKey:`guide.section.subagents.beginner`,advancedKey:`guide.section.subagents.advanced`,includesKey:`guide.section.subagents.includes`,target:`subagents`,Icon:W},{id:`logs`,labelKey:`nav.logs`,beginnerKey:`guide.section.logs.beginner`,advancedKey:`guide.section.logs.advanced`,includesKey:`guide.section.logs.includes`,target:`logs`,Icon:G},{id:`usage`,labelKey:`nav.usage`,beginnerKey:`guide.section.usage.beginner`,advancedKey:`guide.section.usage.advanced`,includesKey:`guide.section.usage.includes`,target:`usage`,Icon:K},{id:`storage`,labelKey:`nav.storage`,beginnerKey:`guide.section.storage.beginner`,advancedKey:`guide.section.storage.advanced`,includesKey:`guide.section.storage.includes`,target:`storage`,Icon:q},{id:`integrations`,labelKey:`nav.integrations`,beginnerKey:`guide.section.integrations.beginner`,advancedKey:`guide.section.integrations.advanced`,includesKey:`guide.section.integrations.includes`,target:`integrations`,Icon:Se},{id:`android-remote`,labelKey:`nav.androidRemote`,beginnerKey:`guide.section.androidRemote.beginner`,advancedKey:`guide.section.androidRemote.advanced`,includesKey:`guide.section.androidRemote.includes`,target:`android-remote`,Icon:Ce},{id:`startup`,labelKey:`nav.startup`,beginnerKey:`guide.section.startup.beginner`,advancedKey:`guide.section.startup.advanced`,includesKey:`guide.section.startup.includes`,target:`startup`,Icon:pe},{id:`sidebar`,labelKey:`guide.section.sidebar.title`,beginnerKey:`guide.section.sidebar.beginner`,advancedKey:`guide.section.sidebar.advanced`,includesKey:`guide.section.sidebar.includes`,Icon:xe}],ig=[`connect`,`models`,`clients`];function ag(){let e=Q(),[t,n]=(0,_.useState)(tg),r=e=>{n(e),ng(e)};return(0,z.jsxs)(`section`,{className:`guide-page`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:e(`guide.title`)})}),(0,z.jsx)(`p`,{className:`page-sub`,children:e(`guide.subtitle`)}),(0,z.jsxs)(`section`,{className:`guide-audience`,"aria-labelledby":`guide-audience-title`,children:[(0,z.jsxs)(`div`,{className:`guide-audience-copy`,children:[(0,z.jsx)(`span`,{className:`guide-eyebrow`,children:e(`guide.mode.label`)}),(0,z.jsx)(`h3`,{id:`guide-audience-title`,children:e(t===`beginner`?`guide.mode.beginnerTitle`:`guide.mode.advancedTitle`)}),(0,z.jsx)(`p`,{children:e(t===`beginner`?`guide.mode.beginnerDescription`:`guide.mode.advancedDescription`)})]}),(0,z.jsx)(`div`,{className:`guide-mode-switch`,role:`group`,"aria-label":e(`guide.mode.label`),children:[`beginner`,`advanced`].map(n=>(0,z.jsx)(`button`,{type:`button`,className:t===n?`active`:``,"data-guide-audience":n,"aria-pressed":t===n,onClick:()=>r(n),children:e(n===`beginner`?`guide.mode.beginner`:`guide.mode.advanced`)},n))})]}),(0,z.jsxs)(`div`,{className:`guide-content`,children:[(0,z.jsxs)(`section`,{className:`guide-block`,"aria-labelledby":`guide-quick-start-title`,children:[(0,z.jsxs)(`div`,{className:`guide-block-head`,children:[(0,z.jsx)(`h3`,{id:`guide-quick-start-title`,children:e(`guide.quickStart.title`)}),(0,z.jsx)(`p`,{children:e(t===`beginner`?`guide.quickStart.subtitle.beginner`:`guide.quickStart.subtitle.advanced`)})]}),(0,z.jsx)(`ol`,{className:`guide-quick-start`,children:ig.map(n=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`h4`,{children:e(`guide.quickStart.${n}.title`)}),(0,z.jsx)(`p`,{children:e(`guide.quickStart.${n}.${t}`)})]},n))})]}),(0,z.jsxs)(`section`,{className:`guide-flow`,"aria-labelledby":`guide-flow-title`,children:[(0,z.jsx)(`div`,{className:`guide-block-head`,children:(0,z.jsx)(`h3`,{id:`guide-flow-title`,children:e(`guide.flow.title`)})}),(0,z.jsxs)(`div`,{className:`guide-flow-row`,"aria-label":e(`guide.flow.aria`),children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(H,{"aria-hidden":!0}),(0,z.jsx)(`strong`,{children:e(`guide.flow.providers`)})]}),(0,z.jsx)(`span`,{className:`guide-flow-line`,"aria-hidden":!0}),(0,z.jsxs)(`div`,{className:`guide-flow-center`,children:[(0,z.jsx)(V,{"aria-hidden":!0}),(0,z.jsx)(`strong`,{children:e(`guide.flow.openCodex`)})]}),(0,z.jsx)(`span`,{className:`guide-flow-line`,"aria-hidden":!0}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(xe,{"aria-hidden":!0}),(0,z.jsx)(`strong`,{children:e(`guide.flow.clients`)})]})]}),(0,z.jsx)(`p`,{children:e(t===`beginner`?`guide.flow.note.beginner`:`guide.flow.note.advanced`)})]}),(0,z.jsxs)(`section`,{className:`guide-block`,"aria-labelledby":`guide-sections-title`,children:[(0,z.jsxs)(`div`,{className:`guide-block-head`,children:[(0,z.jsx)(`h3`,{id:`guide-sections-title`,children:e(`guide.sections.title`)}),(0,z.jsx)(`p`,{children:e(t===`beginner`?`guide.sections.subtitle.beginner`:`guide.sections.subtitle.advanced`)})]}),(0,z.jsx)(`div`,{className:`guide-section-grid`,children:rg.map(n=>{let r=e(n.labelKey),i=n.Icon;return(0,z.jsxs)(`article`,{className:`guide-section-card`,children:[(0,z.jsxs)(`div`,{className:`guide-section-card-head`,children:[(0,z.jsx)(`span`,{className:`guide-section-icon`,children:(0,z.jsx)(i,{"aria-hidden":!0})}),(0,z.jsx)(`h4`,{children:r})]}),(0,z.jsx)(`p`,{children:e(t===`beginner`?n.beginnerKey:n.advancedKey)}),(0,z.jsxs)(`dl`,{children:[(0,z.jsx)(`dt`,{children:e(`guide.section.includes`)}),(0,z.jsx)(`dd`,{children:e(n.includesKey)})]}),n.target&&(0,z.jsx)(`a`,{href:`#${n.target}`,onClick:e=>{e.preventDefault(),Ue(n.target)},children:e(`guide.section.open`,{section:r})})]},n.id)})})]})]})]})}function og(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&typeof t.installed==`boolean`&&typeof t.running==`boolean`&&typeof t.stale==`boolean`&&typeof t.summary==`string`}var sg={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},cg={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},lg={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function ug({ok:e,yes:t,no:n}){return(0,z.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function dg({failed:e,data:t}){let{t:n}=Z(),r=e?`startup-hero--risk`:t.status===`protected`?`startup-hero--safe`:t.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,i=e||t.status===`at-risk`?oe:J,a=t.routingKind===`opencodex-local`?`startup.routing.proxy`:t.routingKind===`custom-local`?`startup.routing.customLocal`:t.routingKind===`custom-remote`?`startup.routing.customRemote`:t.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,z.jsx)(`div`,{className:`startup-hero-icon`,children:(0,z.jsx)(i,{})}),(0,z.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,z.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:sg[t.status])}),(0,z.jsx)(`h3`,{children:n(e?`startup.error`:cg[t.status])}),(0,z.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(On(t)):n(`startup.safeDetail`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.routing`)}),(0,z.jsx)(`div`,{className:`value`,children:n(a)})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.restartProtection`)}),(0,z.jsx)(`div`,{className:`value`,children:n(lg[t.protection])})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.preference`)}),(0,z.jsx)(`div`,{className:`value`,children:n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]})]})}function fg({data:e,failed:t,loading:n=!1,installBusy:r,installResult:i,onInstall:a}){let{t:o}=Z(),s=e.serviceSupported&&e.serviceInstalled&&e.serviceStale&&!e.serviceConflict,c=e.shimInstalled&&!e.shimHealthy,l=r!==null||t||n;return(0,z.jsxs)(`section`,{className:`panel startup-details`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:o(`startup.details`)}),(0,z.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.service`)}),(0,z.jsx)(`span`,{children:o(`startup.serviceHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(ug,{ok:e.serviceViable,yes:o(`startup.viable`),no:o(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-service`),children:o(r===`install-service`?`startup.installing`:`startup.install`)}),s&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-service`,{repair:!0}),children:o(r===`install-service`?`startup.repairing`:`startup.repair`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.shim`)}),(0,z.jsx)(`span`,{children:o(`startup.shimHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(ug,{ok:e.shimHealthy&&e.autostartEnabled,yes:o(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:o(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-shim`),children:o(r===`install-shim`?`startup.installing`:`startup.install`)}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-shim`,{repair:!0}),children:o(r===`install-shim`?`startup.repairing`:`startup.repair`)})]})]}),i&&(0,z.jsx)(`div`,{className:`notice ${i.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:i.kind===`success`?i.action===`install-service`?o(i.repair?`startup.serviceRepaired`:`startup.serviceInstalled`):o(i.repair?`startup.shimRepaired`:`startup.shimInstalled`):`${o(`startup.installFailed`)} ${i.detail??``}`})]})}function pg({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=Z();return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,z.jsx)(pe,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,z.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,z.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,z.jsx)(ug,{ok:e.running&&!e.stale,yes:a(`startup.tray.running`),no:a(e.stale?`startup.tray.stale`:e.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,z.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`install`),children:a(`startup.tray.install`)}),!t&&!n&&e?.installed&&!e.stale&&!e.running&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`start`),children:a(`startup.tray.start`)}),!t&&!n&&e?.running&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:r,onClick:()=>i(`stop`),children:a(`startup.tray.stop`)}),!t&&!n&&e&&(e.installed||e.stale)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:r,onClick:()=>{window.confirm(a(`startup.tray.uninstall`))&&i(`uninstall`)},children:a(`startup.tray.uninstall`)})]}),(n||e?.stale)&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-tray-error`,role:`alert`,children:a(`startup.tray.error`)})]})}function mg({data:e,copied:t,onCopy:n}){let{t:r}=Z(),i=jm(e.serviceInstalled&&!e.serviceConflict?e.commands.repairService:e.commands.installService),a=jm(e.commands.installShim),o=jm(e.commands.restoreNative),s=jm(e.recommendedCommand??e.commands.installService);return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,z.jsx)(te,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,z.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,z.jsx)(`code`,{children:i})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(i),children:r(t===i?`startup.copied`:`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,z.jsx)(`code`,{children:a})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(a),children:r(t===a?`startup.copied`:`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,z.jsx)(`code`,{children:o})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(o),children:r(t===o?`startup.copied`:`startup.copy`)})]})]}),e.status===`at-risk`&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,z.jsx)(pe,{}),` `,r(`startup.recommended`,{cmd:s})]})]})}var hg=`ocx.startup.page.v1:`;function gg(e,t){let n=t===`win32`?`; `:` && `;return e.join(n)}function _g(e,t,n){if(!e)return{warning:null,fix:null};let r=!!e.catalogClamp?.active,i=!!e.newerAvailable,a=(r?e.catalogClamp?.runtimeVersion:e.version)??e.version??`unknown`,o=(e.catalogClamp?.removedEfforts??[]).join(`, `),s=gg([`rmx doctor --fix-codex-runtime`,`rmx sync`],n);return r?{warning:o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}),fix:i?s:`rmx sync`}:i?{warning:t(`startup.codexRuntime.olderBinary`,{version:a}),fix:s}:{warning:null,fix:null}}function vg({apiBase:e}){let{t}=Z(),n=`${hg}${e}`,r=(0,_.useMemo)(()=>En(n),[n]),i=`startup-page:${e}`,[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(()=>r?.tray??null),[l,u]=(0,_.useState)(()=>!r?.data),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(()=>r?.warning??null),[S,C]=(0,_.useState)(()=>r?.fix??null),[w,T]=(0,_.useState)(()=>!r?.data),E=(0,_.useRef)(!!r?.data),D=(0,_.useCallback)(async r=>{let i=E.current;i||(u(!0),T(!0));try{let i=fetch(`${e}/api/settings`,{signal:r}).then(async e=>e.ok?await e.json():null).catch(()=>null),a=await fetch(`${e}/api/startup-health`,{signal:r});if(!a.ok)throw Error(`fetch failed`);let o=await a.json();y(e=>e?.kind===`error`&&(o.status===`native`&&e.forLocalRouting===!0||(e.action===`install-service`?o.serviceViable:o.shimInstalled&&o.shimHealthy))?null:e),E.current=!0;let s=En(n);Dn(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:s?.tray??null});let l=o.platform===`win32`?fetch(`${e}/api/windows-tray`,{signal:r}).then(async e=>{if(!e.ok)throw Error(`tray status failed`);let t=await e.json();if(!og(t))throw Error(`invalid tray status`);return{tray:t,error:!1}}).catch(()=>({tray:null,error:!0})):Promise.resolve({tray:null,error:!1});return Promise.all([i,l]).then(([e,i])=>{if(r.aborted)return;let a=o.platform===`win32`?i.tray:null;if(o.platform===`win32`?(c(a),m(i.error)):(c(null),m(!1)),u(!1),T(!1),e){let r=_g(e.codexRuntime,t,o.platform);x(r.warning),C(r.fix),Dn(n,{data:o,warning:r.warning,fix:r.fix,tray:a});return}let s=En(n);Dn(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:a})}),o}catch(e){throw r.aborted?e:(i||(c(null),m(!0),x(null),C(null)),T(!1),u(!1),e)}},[e,n,t]),O=bs(i,[e],D,{isEmpty:()=>!1,initialData:r?.data??void 0}),k=O.state,A=O.refresh,j=k.data??r?.data??null,M=k.refreshing,N=!!j?.diagnosticStale||k.showError;(0,_.useEffect)(()=>{if(!j?.diagnosticStale)return;let e=window.setTimeout(A,2e3);return()=>window.clearTimeout(e)},[j,A]);let P=async e=>{try{await navigator.clipboard.writeText(e),o(e),window.setTimeout(()=>o(t=>t===e?null:t),1600)}catch{o(null)}},F=async t=>{f(!0),m(!1);try{let n=await fetch(`${e}/api/windows-tray`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok)throw Error(`tray action failed`);let r=await n.json();if(!og(r.status))throw Error(`invalid tray action status`);c(r.status),m(!1)}catch{c(null),m(!0)}finally{f(!1)}},I=async(t,n)=>{g(t),y(null);try{let r=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,repair:n?.repair===!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}y({kind:`success`,action:t,repair:n?.repair===!0}),A()}catch(e){y({kind:`error`,action:t,repair:n?.repair===!0,detail:e instanceof Error?e.message:String(e),forLocalRouting:j?.localRoutingDependency===!0})}finally{g(null)}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{children:t(`startup.title`)}),(0,z.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,z.jsxs)(`div`,{className:`startup-page-head-actions`,children:[(0,z.jsx)(`a`,{className:`btn btn-ghost btn-sm`,href:`#dashboard`,children:t(`startup.backToDashboard`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),disabled:M,children:[(0,z.jsx)(X,{}),` `,t(`startup.refresh`)]})]})]}),k.showSkeleton&&!j?(0,z.jsx)(Ss,{label:t(`startup.loading`),rows:5}):k.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`startup-page-notice`,children:[(0,z.jsx)($,{tone:`err`,children:k.error instanceof Error?k.error.message:t(`startup.error`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),children:t(`common.retry`)})]}):j?(0,z.jsxs)(z.Fragment,{children:[k.showError&&(0,z.jsx)($,{tone:`err`,children:t(`startup.error`)}),N&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-page-notice`,role:`alert`,children:t(`startup.staleData`)}),(w||b)&&(0,z.jsx)(`div`,{className:`startup-runtime-notice-slot${w&&!b?` startup-runtime-notice-slot--pending`:``}`,"aria-hidden":w&&!b?!0:void 0,children:b&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-page-notice startup-runtime-notice`,role:`status`,children:[(0,z.jsx)(`p`,{className:`startup-runtime-notice__text`,children:b}),S&&(0,z.jsxs)(`div`,{className:`startup-runtime-notice__fix`,children:[(0,z.jsx)(`code`,{children:S}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void P(S),children:t(a===S?`startup.copied`:`startup.copy`)})]})]})}),(0,z.jsx)(dg,{failed:N,data:j}),(0,z.jsx)(fg,{data:j,failed:N,loading:M,installBusy:h,installResult:v,onInstall:(e,t)=>{I(e,t)}}),j.platform===`win32`&&(0,z.jsx)(pg,{tray:s,trayLoading:l,trayError:p,trayBusy:d,onTrayAction:e=>{F(e)}}),(0,z.jsx)(mg,{data:j,copied:a,onCopy:e=>{P(e)}})]}):null]})}function yg({onOpenUpdate:e}){let t=Q();return(0,z.jsxs)(`button`,{type:`button`,className:`sidebar-link sidebar-update-action`,onClick:e,"aria-label":t(`sidebar.checkUpdate`),title:t(`sidebar.checkUpdate`),children:[(0,z.jsx)(de,{"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t(`sidebar.checkUpdate`)})]})}var bg=`opencodex-admin-token-dialog`,xg=`Remodex`;function Sg(e,t=Fe()){let n=Ae[t],r=n[`auth.adminTokenTitle`];return new Promise(t=>{let i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=!1,o=document.createElement(`dialog`);o.id=bg,o.className=`modal-overlay`,o.setAttribute(`aria-labelledby`,`${bg}-title`);let s=document.createElement(`form`);s.className=`modal-card`,s.method=`post`,s.action=window.location.href,s.autocomplete=`on`;let c=document.createElement(`div`);c.className=`modal-head`;let l=document.createElement(`h3`);l.id=`${bg}-title`,l.textContent=r,c.append(l);let u=document.createElement(`div`),d=document.createElement(`label`);d.className=`field-label`,d.htmlFor=`${bg}-username`,d.textContent=n[`auth.adminAccountLabel`];let f=document.createElement(`input`);f.id=d.htmlFor,f.className=`input`,f.type=`text`,f.name=`username`,f.autocomplete=`username`,f.value=xg,f.readOnly=!0,u.append(d,f);let p=document.createElement(`div`);p.style.marginTop=`var(--space-4)`;let m=document.createElement(`label`);m.className=`field-label`,m.htmlFor=`${bg}-password`,m.textContent=n[`auth.adminTokenFieldLabel`];let h=document.createElement(`input`);h.id=m.htmlFor,h.className=`input`,h.type=`password`,h.name=`password`,h.autocomplete=`current-password`,h.required=!0,h.spellcheck=!1,h.autocapitalize=`none`,p.append(m,h);let g=document.createElement(`div`);g.className=`notice notice-err`,g.setAttribute(`role`,`alert`),g.hidden=!0;let _=document.createElement(`div`);_.className=`modal-actions`;let v=document.createElement(`button`);v.type=`button`,v.className=`btn btn-ghost`,v.textContent=n[`common.cancel`];let y=document.createElement(`button`);y.type=`submit`,y.className=`btn btn-primary`,y.textContent=n[`common.ok`],_.append(v,y),s.append(c,u,p,g,_),o.append(s);let b=e=>{a||(a=!0,o.open&&o.close(),o.remove(),i?.focus(),t(e))};s.addEventListener(`submit`,t=>{t.preventDefault();let r=h.value.trim();if(!r){h.value=``,h.reportValidity();return}h.disabled=!0,y.disabled=!0,g.hidden=!0,e(r).then(e=>{if(!a){if(e===`accepted`){b(r);return}h.value=``,h.disabled=!1,y.disabled=!1,g.textContent=e===`rejected`?n[`auth.adminTokenRejected`]:n[`auth.adminTokenUnavailable`],g.hidden=!1,h.focus()}}).catch(()=>{a||(h.value=``,h.disabled=!1,y.disabled=!1,g.textContent=n[`auth.adminTokenUnavailable`],g.hidden=!1,h.focus())})}),v.addEventListener(`click`,()=>b(null)),o.addEventListener(`cancel`,e=>{e.preventDefault(),b(null)}),document.body.append(o),typeof o.showModal==`function`?o.showModal():o.setAttribute(`open`,``),queueMicrotask(()=>h.focus())})}var Cg=!1,wg=null,Tg=null,Eg=!1,Dg=Sg,Og=`/opencodex-session`,kg=`/api/settings`;function Ag(e){try{let t=e instanceof Request?e.url:String(e),n=new URL(t,window.location.href);return n.origin===window.location.origin&&n.pathname.startsWith(`/api/`)}catch{return!1}}var jg=`opencodex-api-token`,Mg=null,Ng=null,Pg=null;function Fg(){return Mg}function Ig(e){Mg=e}function Lg(){Mg=null,Ng=null,Pg=null}function Rg(e){let t=document.querySelector(`meta[name="${e}"]`),n=t?.content.trim()||null;return t?.remove(),n}function zg(){Vg(Rg(`opencodex-session-token`),Rg(`opencodex-session-csrf`),Rg(`opencodex-session-origin`))}function Bg(e){e!=null&&Fg()===e&&Lg()}function Vg(e,t,n){return!e?.startsWith(`ocx_session_`)||!t||n!==window.location.origin?!1:(Mg=e,Ng=t,Pg=n,!0)}function Hg(e,t){for(let n of e.match(/<meta\b[^>]*>/gi)??[])if(n.match(/\bname="([^"]+)"/i)?.[1]===t)return n.match(/\bcontent="([^"]*)"/i)?.[1]?.trim()||null;return null}async function Ug(){if(!Tg)return null;try{let e=await Tg(Og,{cache:`no-store`});if(!e.ok)return null;let t=await e.text();return Vg(Hg(t,`opencodex-session-token`),Hg(t,`opencodex-session-csrf`),Hg(t,`opencodex-session-origin`))?Fg():null}catch{return null}}async function Wg(e){if(!Tg)return`unavailable`;try{let[t,n]=Kg(kg,{cache:`no-store`},e),r=await Tg(t,n);return r.status===401?`rejected`:r.ok?`accepted`:`unavailable`}catch{return`unavailable`}}function Gg(){try{sessionStorage.removeItem(jg)}catch{}}function Kg(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));if(r.set(`X-OpenCodex-API-Key`,n),Pg&&Ng&&n.startsWith(`ocx_session_`)){r.set(`X-OpenCodex-GUI-Origin`,Pg);let n=(t?.method??(e instanceof Request?e.method:`GET`)).toUpperCase();n!==`GET`&&n!==`HEAD`&&r.set(`X-OpenCodex-CSRF-Token`,Ng)}return e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function qg(e){return Eg?null:wg||(wg=(async()=>{if(Eg)return null;let t=Fg();if(t&&t!==e)return t;let n=await Ug();if(n)return n;let r=await Dg(Wg);return r?(Ig(r),r):(Eg=!0,null)})().finally(()=>{wg=null}),wg)}function Jg(){if(Cg)return;Cg=!0,Gg(),zg();let e=window.fetch.bind(window);Tg=e,window.fetch=async(t,n)=>{if(!Ag(t))return e(t,n);let r=Fg(),[i,a]=r?Kg(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;let s=Fg();if(s&&s!==r){let[r,i]=Kg(t,n,s),a=await e(r,i);if(a.status!==401)return a;Bg(s)}else Bg(r);let c=await qg(r);if(!c)return o;let[l,u]=Kg(t,n,c),d=await e(l,u);return d.status===401&&Bg(c),d}}var Yg=[`ocx-global-view`,`ocx-view`,`ocx-providers-view`,`ocx-subagents-view`,`ocx-storage-view`,`ocx-codexauth-view`,`ocx-apikeys-view`,`ocx-claudecode-view`,`ocx-usage-view`,`ocx-logs-view`,`ocx-models-view`,`ocx-dashboard-view`];function Xg(){try{for(let e of Yg)localStorage.removeItem(e)}catch{}}function Zg(){let[e,t]=(0,_.useState)(vh);(0,_.useEffect)(()=>{Xg()},[]);let n=(0,_.useCallback)(e=>{let n=Ch(e);n.replaceTo&&He(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(Ve(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let n=Ch(Ve(window.location.hash));n.replaceTo&&He(n.replaceTo),n.page!==e&&t(n.page)},[e]),{page:e,setPageState:t,navigateToPage:(e,n)=>{Ue(n?`${e}/${n}`:e),t(e)}}}var Qg=15e3;function $g(e,t,n){return typeof e?.message==`string`&&e.message.trim()?e.message:typeof e?.error==`string`&&e.error.trim()?e.error:n(t)}function e_(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}async function t_(e,t={}){let{fetchFn:n=fetch,timeoutMs:r=Qg,formatFailure:i=e=>`Failed to stop proxy (HTTP ${e}).`}=t,a;try{a=await n(`${e}/api/stop`,{method:`POST`,signal:AbortSignal.timeout(r)})}catch(e){return e_(e),{accepted:!0}}let o=await a.json().catch(()=>null);return!a.ok||o?.success===!1?{accepted:!1,message:$g(o,a.status,i)}:{accepted:!0}}Jg();var n_={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,subagents:`nav.subagents`,logs:`nav.logs`,"desktop-logs":`nav.desktopLogs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,integrations:`nav.integrations`,"android-remote":`nav.androidRemote`,guide:`nav.guide`},r_=``,i_=`ocx-theme`,a_=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:V},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:he},{id:`providers`,tkey:`nav.providers`,Icon:H},{id:`models`,tkey:`nav.models`,Icon:U},{id:`subagents`,tkey:`nav.subagents`,Icon:W},{id:`logs`,tkey:`nav.logs`,Icon:G},{id:`desktop-logs`,tkey:`nav.desktopLogs`,Icon:te},{id:`usage`,tkey:`nav.usage`,Icon:K},{id:`storage`,tkey:`nav.storage`,Icon:q},{id:`integrations`,tkey:`nav.integrations`,Icon:Se},{id:`android-remote`,tkey:`nav.androidRemote`,Icon:Ce},{id:`guide`,tkey:`nav.guide`,Icon:we}],o_={light:ye,dark:be,system:xe},s_={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function c_(e){if(!e||typeof e!=`object`||!(`version`in e))return null;let t=e.version;return typeof t==`string`&&t.length>0?t:null}function l_(){let e=localStorage.getItem(i_);return e===`light`||e===`dark`?e:`system`}function u_(){let{page:e,navigateToPage:t}=Zg(),[n,r]=(0,_.useState)(il);(0,_.useEffect)(()=>{let e=()=>r(il());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let[i,a]=(0,_.useState)(l_),{locale:o,setLocale:s}=Z(),c=Q(),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>u(!1);return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]),(0,_.useEffect)(()=>{let e=document.documentElement;i===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(i_)):(e.setAttribute(`data-theme`,i),localStorage.setItem(i_,i))},[i]);let m=I(`app-healthz:${r_}`,[],async e=>{let t=await fetch(`${r_}/healthz`,{signal:e});return t.ok?c_(await t.json()):null},{pollMs:3e4}),h=()=>a(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),g=o_[i],v=m.data??`1.0.4`,[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),C=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=!1,t,n=async()=>{let r=await Os();!e&&r&&S(r),e||(t=setTimeout(n,1e3))};return n(),()=>{e=!0,t&&clearTimeout(t)}},[]),(0,_.useEffect)(()=>{if(x){if(x.state===`offline`){C.current=!0;return}C.current&&(x.state===`ready`||x.state===`degraded`)&&window.location.reload()}},[x]),(0,_.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[l]),(0,_.useEffect)(()=>{if(l){p.current=!0;let e=setTimeout(()=>f.current?.focus(),200);return()=>clearTimeout(e)}p.current&&(p.current=!1,d.current?.focus())},[l]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&u(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let w=async()=>{let e=x?.state===`offline`;if(!e&&!confirm(c(`dash.stopConfirm`)))return;if(b(!0),x){try{S(await ks(e))}catch(t){let n=t instanceof Error?t.message:String(t);alert(c(e?`dash.startFailed`:`dash.lifecycleFailed`,{message:n}))}finally{b(!1)}return}let t=await t_(r_,{formatFailure:e=>c(`dash.stopFailed`,{status:String(e)})});t.accepted||(b(!1),alert(t.message))},T=x?.state===`offline`?`dash.start`:x?.state===`starting`?`dash.starting`:x?.state===`stopping`||y?`dash.stopping`:`dash.stop`,E=y||x?.state===`starting`||x?.state===`stopping`,D=(0,z.jsxs)(`div`,{className:`brand`,children:[(0,z.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":c(`app.logoAria`)}),(0,z.jsx)(`span`,{className:`name`,children:`Remodex`}),(0,z.jsxs)(`span`,{className:`ver`,children:[`v`,v]})]});return(0,z.jsxs)(`div`,{className:`app`,children:[(0,z.jsxs)(`header`,{className:`mobile-topbar`,inert:l,children:[(0,z.jsx)(`button`,{ref:d,type:`button`,className:`menu-toggle`,onClick:()=>u(e=>!e),"aria-expanded":l,"aria-controls":`app-sidebar`,"aria-label":c(l?`nav.closeMenu`:`nav.openMenu`),title:c(l?`nav.closeMenu`:`nav.openMenu`),children:(0,z.jsx)(ee,{})}),D,(0,z.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:w,disabled:E,"aria-label":c(T),title:c(T),children:(0,z.jsx)(pe,{})})]}),l&&(0,z.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>u(!1),"aria-hidden":`true`}),(0,z.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${l?` open`:``}`,ref:f,tabIndex:-1,children:[(0,z.jsxs)(`div`,{className:`drawer-head`,children:[D,(0,z.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>u(!1),"aria-label":c(`nav.closeMenu`),title:c(`nav.closeMenu`),children:(0,z.jsx)(Y,{})})]}),(0,z.jsx)(`nav`,{children:a_.map(n=>{let{id:r,tkey:i,Icon:a}=n,o=r===e;return(0,z.jsx)(`div`,{className:`nav-entry`,children:(0,z.jsxs)(`button`,{type:`button`,className:`nav-item${o?` active`:``}`,"data-page":r,onClick:()=>{t(r),u(!1)},"aria-current":o?`page`:void 0,children:[(0,z.jsx)(a,{}),` `,c(i)]})},r)})}),(0,z.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,z.jsxs)(`div`,{className:`lang-toggle`,children:[(0,z.jsx)(Se,{"aria-hidden":!0}),(0,z.jsx)(rt,{value:o,options:je.map(e=>({value:e.code,label:e.name})),onChange:e=>s(e),label:c(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:h,"aria-label":`${c(`theme.label`)}: ${c(s_[i])}`,title:`${c(`theme.label`)}: ${c(s_[i])}`,children:[(0,z.jsx)(g,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:c(s_[i])})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:w,disabled:E,"aria-label":c(T),title:c(T),children:[(0,z.jsx)(pe,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:c(T)})]}),(0,z.jsx)(yg,{onOpenUpdate:()=>{u(!1),t(`dashboard`,`update`)}})]})]}),(0,z.jsx)(`main`,{className:`main`,inert:l,children:(0,z.jsx)(`div`,{className:`main-inner${e===`models`&&n===`combos`?` main-inner--combos`:``}`,children:(0,z.jsxs)(Ns,{pageName:c(n_[e]),title:c(`errorBoundary.title`),message:c(`errorBoundary.message`),detailsLabel:c(`errorBoundary.details`),reloadLabel:c(`errorBoundary.reload`),children:[e===`dashboard`&&(0,z.jsx)(tr,{apiBase:r_}),e===`startup`&&(0,z.jsx)(vg,{apiBase:r_}),e===`providers`&&(0,z.jsx)(ps,{apiBase:r_}),e===`models`&&(0,z.jsx)(Pl,{apiBase:r_},r_),e===`subagents`&&(0,z.jsx)(Wl,{apiBase:r_},r_),e===`logs`&&(0,z.jsx)(md,{apiBase:r_}),e===`desktop-logs`&&(0,z.jsx)(xd,{}),e===`usage`&&(0,z.jsx)(Vd,{apiBase:r_}),e===`storage`&&(0,z.jsx)(af,{apiBase:r_}),e===`codex-auth`&&(0,z.jsx)(ff,{apiBase:r_}),e===`integrations`&&(0,z.jsx)(oh,{apiBase:r_}),e===`android-remote`&&(0,z.jsx)(Qh,{apiBase:r_}),e===`guide`&&(0,z.jsx)(ag,{})]},e)})})]})}var d_=new WeakSet,f_=new Map,p_=5e3,m_=64,h_=8e3;function g_(e){if(e)return e.length<=h_?e:`${e.slice(0,7999)}…`}function __(e){return e instanceof Error?{message:g_(e.message)||e.name||`Unhandled error`,stack:g_(e.stack)}:typeof e==`string`?{message:g_(e)||`Unhandled rejection`}:e===null?{message:`Unhandled rejection: null`}:e===void 0?{message:`Unhandled rejection: undefined`}:{message:`Unhandled rejection: ${Object.prototype.toString.call(e)}`}}function v_(e){let t=Date.now(),n=`${e.kind}\u0000${e.message}\u0000${e.source??``}`,r=f_.get(n);if(r!==void 0&&t-r<p_)return!1;if(f_.set(n,t),f_.size>m_){let e=[...f_.entries()].sort((e,t)=>e[1]-t[1])[0];e&&f_.delete(e[0])}return!0}function y_(e){v_(e)&&Ms(e)}function b_(e=window){d_.has(e)||(d_.add(e),e.addEventListener(`error`,t=>{let n=__(t.error??t.message);y_({kind:`window-error`,message:n.message,stack:n.stack,source:g_([t.filename,t.lineno>0?String(t.lineno):``,t.colno>0?String(t.colno):``].filter(Boolean).join(`:`)),page:g_(e.location.hash||`#dashboard`)})}),e.addEventListener(`unhandledrejection`,t=>{let n=__(t.reason);y_({kind:`unhandled-rejection`,message:n.message,stack:n.stack,page:g_(e.location.hash||`#dashboard`)})}))}b_(),g.createRoot(document.getElementById(`root`)).render((0,z.jsx)(_.StrictMode,{children:(0,z.jsx)(ze,{children:(0,z.jsx)(u_,{})})}));
71
+ `);if(!confirm(t))return;i(!0),o(null);let a=[];for(let t of N)try{await Zp(e,t.clientId,!1)}catch(e){a.push(`${t.clientId}: ${Sm(n,e)}`)}let s=!1;try{s=(await Jp(e)).clients.some(qm)}catch{a.push(n(`integrations.error.stale`))}s&&a.length===0&&a.push(n(`integrations.error.stale`)),U(),i(!1),o(a.length===0?{tone:`ok`,text:n(`integrations.bulk.success`)}:{tone:`err`,text:n(`integrations.bulk.partial`,{clients:a.join(`; `)})})},G=M[0]?.at,[ee,te]=(0,_.useState)(null),K=()=>{A.refresh(),D.refresh(),k.refresh()},q=(e,t)=>{u(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},J=async(t,r)=>{if(!ee&&t.toggle){te(t.id),q(t.id,null);try{if(t.status)await Zp(e,t.status.clientId,r),U();else if(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`){let i=await hm(e,t.toggle,r);i.reason===`non_loopback_removed`?q(t.id,{tone:`ok`,text:n(i.changed?`integrations.native.msg.nonLoopbackRemoved`:`integrations.native.msg.nonLoopbackRemovedNoop`)}):i.reason===`non_loopback_superseded`&&q(t.id,{tone:`ok`,text:n(`integrations.native.msg.nonLoopbackSuperseded`)}),K()}}catch(e){q(t.id,{tone:`err`,text:Sm(n,e,void 0,t.togglePath??void 0)}),(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`)&&K()}finally{te(null)}}},Y=(e,t)=>{if(e.status||t||e.id===`claude`||e.toggle===null){J(e,t);return}let n=document.activeElement;p.current=n?.tagName===`BUTTON`?n:null,f(e)};return(0,z.jsxs)(`section`,{className:`integrations-overview`,children:[(0,z.jsxs)(`div`,{className:`integration-summary`,children:[(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.detected`)}),(0,z.jsx)(`strong`,{children:H.detected})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.applied`)}),(0,z.jsx)(`strong`,{children:H.applied})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.stale`)}),(0,z.jsx)(`strong`,{children:H.stale})]}),H.unknown>0&&(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.state.unknown`)}),(0,z.jsx)(`strong`,{children:H.unknown})]}),(0,z.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,z.jsx)(`span`,{className:`integration-summary-label`,children:n(`integrations.summary.lastChange`)}),(0,z.jsx)(`strong`,{children:G?new Date(G).toLocaleString():n(`integrations.status.unknown`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void W(),disabled:r||N.length===0,children:n(`integrations.summary.disableAll`)})]}),(0,z.jsx)(Xm,{row:B}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.onboarding`)}),C.state.kind===`failed-cold`&&(0,z.jsx)($,{tone:`err`,children:n(`integrations.error.load`)}),C.state.kind===`failed-with-stale`&&(0,z.jsx)($,{tone:`err`,children:n(`integrations.error.stale`)}),a&&(0,z.jsx)($,{tone:a.tone,children:a.text}),V.length===0?C.state.kind===`failed-cold`?null:(0,z.jsx)(`p`,{className:`page-sub`,children:n(`common.loading`)}):(0,z.jsx)(`ul`,{className:`integration-cards`,children:V.map(e=>(0,z.jsx)(Jm,{row:e,pending:ee!==null,result:l[e.id]??null,onOpen:()=>Ue(e.hash),onToggle:e.toggle?()=>Y(e,!(e.toggleOn??e.applied)):null},e.id))}),F&&P.length===0&&(0,z.jsxs)(`div`,{className:`integration-empty`,children:[(0,z.jsx)(`h4`,{children:n(`integrations.empty.title`)}),(0,z.jsx)(`p`,{children:n(`integrations.empty.body`)})]}),(0,z.jsx)(`h4`,{children:n(`integrations.rollback.title`)}),M.length===0?(0,z.jsxs)(`div`,{className:`integration-empty`,children:[(0,z.jsx)(`p`,{children:n(`integrations.rollback.empty`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:n(`integrations.rollback.emptyBody`)})]}):(0,z.jsx)(`ul`,{className:`integration-history`,children:M.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`integration-history-kind`,children:n(Km[e.kind])}),(0,z.jsx)(`span`,{className:`integration-history-client`,children:e.clientId}),(0,z.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,z.jsx)(`span`,{className:`badge badge-muted`,children:n(`integrations.action.snapshotExpired`)}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>c(e),children:e.undoable?n(`integrations.action.undo`):n(`integrations.action.restorePoint`)})]},e.opId))}),s&&(0,z.jsx)(Am,{apiBase:e,row:s,onClose:()=>c(null),onRestored:U}),d&&(0,z.jsx)(Rp,{copy:{...d.toggle===`claude-desktop`?Gm:Wm,vars:{path:d.togglePath??``}},onClose:()=>f(null),onConfirm:async()=>{await J(d,!1),f(null)}})]})}function Xm({row:e}){let t=Q(),n=e.detailKey?t(e.detailKey,e.detailVars??void 0):null;return(0,z.jsxs)(`div`,{className:`integration-api-keys-row`,"data-client":`keys`,"data-key-state":e.state,children:[(0,z.jsxs)(`div`,{className:`integration-api-keys-copy`,children:[(0,z.jsx)(`h4`,{children:t(e.labelKey)}),n&&(0,z.jsx)(`p`,{className:`integration-meta`,children:n})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>Ue(e.hash),children:t(`integrations.action.manageKeys`)})]})}var Zm={opencode:`integrations.semantics.opencode`,pi:`integrations.semantics.pi`,omp:`integrations.semantics.omp`,hermes:`integrations.semantics.hermes`,openclaw:`integrations.semantics.openclaw`,kimi:`integrations.semantics.kimi`,gajae:`integrations.semantics.gajae`},Qm={opencode:`integrations.tab.opencode`,pi:`integrations.tab.pi`,omp:`integrations.tab.omp`,hermes:`integrations.tab.hermes`,openclaw:`integrations.tab.openclaw`,kimi:`integrations.tab.kimi`,gajae:`integrations.tab.gajae`},$m={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`};function eh({apiBase:e,client:t,active:n=!0}){let r=Q(),[i,a]=(0,_.useState)(!1),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),u=(0,_.useCallback)(n=>Yp(e,t,n),[e,t]),d=(0,_.useCallback)(async n=>(await Xp(e,t,n)).operations,[e,t]),f=bs(`integration-state:${e}:${t}`,[e,t],u,{isEmpty:()=>!1,enabled:n}),p=bs(`integration-journal:${e}:${t}`,[e,t],d,{isEmpty:e=>e.length===0,enabled:n}),m=f.state.data??null,h=p.state.data??[],g=()=>{f.refresh(),p.refresh()},v=async n=>{if(!(!m||i)){a(!0),s(null);try{await Zp(e,t,n),g()}catch(e){s(Sm(r,e))}finally{a(!1)}}},y=()=>void v(!(m&&(m.state===`current`||m.state===`stale`)));if(!m)return(0,z.jsx)(`section`,{className:`integration-client-page`,children:f.state.kind===`failed-cold`?(0,z.jsx)($,{tone:`err`,children:r(`integrations.error.load`)}):(0,z.jsx)(`p`,{className:`page-sub`,children:r(`common.loading`)})});let b=m.state===`current`||m.state===`stale`,x=!m.installed||m.state===`conflict`||m.state===`unsafe`;return(0,z.jsxs)(`section`,{className:`integration-client-page`,children:[(0,z.jsxs)(`div`,{className:`integration-client-head`,children:[(0,z.jsx)(`h3`,{children:r(Qm[t])}),(0,z.jsx)(km,{state:m.state,installed:m.installed,id:`integration-state-${t}`}),(0,z.jsx)(tt,{on:b,onClick:y,disabled:x||i,label:r(b?`integrations.action.disable`:`integrations.action.apply`)})]}),m.state===`stale`&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void v(!0),disabled:i,children:r(`integrations.action.refresh`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:r(Zm[t])}),(0,z.jsx)(`p`,{className:`integration-path`,children:m.configPath}),m.appliedAt&&(0,z.jsxs)(`p`,{className:`integration-meta`,children:[r(`integrations.status.appliedAt`),`: `,new Date(m.appliedAt).toLocaleString()]}),m.retentionDegraded&&(0,z.jsx)($,{tone:`err`,children:r(`integrations.retention.degraded`)}),o&&(0,z.jsx)($,{tone:`err`,children:o}),(0,z.jsx)(`h4`,{children:r(`integrations.rollback.title`)}),h.length===0?(0,z.jsx)(`p`,{className:`page-sub`,children:r(`integrations.rollback.empty`)}):(0,z.jsx)(`ul`,{className:`integration-history`,children:h.map(e=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`span`,{className:`integration-history-kind`,children:r($m[e.kind])}),(0,z.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,z.jsx)(`span`,{className:`badge badge-muted`,children:r(`integrations.action.snapshotExpired`)}):(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>l(e),children:e.undoable?r(`integrations.action.undo`):r(`integrations.action.restorePoint`)})]},e.opId))}),c&&(0,z.jsx)(Am,{apiBase:e,row:c,onClose:()=>l(null),onRestored:g})]})}var th=[{id:`overview`,hash:`integrations`,labelKey:`integrations.tab.overview`},{id:`keys`,hash:`integrations/keys`,labelKey:`integrations.tab.keys`},{id:`codex`,hash:`integrations/codex`,labelKey:`integrations.tab.codex`},{id:`claude`,hash:`integrations/claude`,labelKey:`integrations.tab.claude`},{id:`grok`,hash:`integrations/grok`,labelKey:`integrations.tab.grok`},{id:`opencode`,hash:`integrations/opencode`,labelKey:`integrations.tab.opencode`},{id:`pi`,hash:`integrations/pi`,labelKey:`integrations.tab.pi`},{id:`omp`,hash:`integrations/omp`,labelKey:`integrations.tab.omp`},{id:`hermes`,hash:`integrations/hermes`,labelKey:`integrations.tab.hermes`},{id:`openclaw`,hash:`integrations/openclaw`,labelKey:`integrations.tab.openclaw`},{id:`kimi`,hash:`integrations/kimi`,labelKey:`integrations.tab.kimi`},{id:`gajae`,hash:`integrations/gajae`,labelKey:`integrations.tab.gajae`}],nh=new Set([`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`]);function rh(e=window.location.hash){let t=Ve(e);return t===`integrations/claude/desktop`?`claude`:th.find(e=>e.hash===t)?.id??`overview`}function ih(e){return`integrations-tab-${e}`}function ah(e){return`integrations-panel-${e}`}function oh({apiBase:e}){let t=Q(),[n,r]=(0,_.useState)(rh),[i,a]=(0,_.useState)(()=>new Set([rh()])),o=(0,_.useRef)(null);o.current===null&&(o.current=new Map);let s=e=>{r(e),a(t=>t.has(e)?t:new Set([...t,e]))};(0,_.useEffect)(()=>{let e=()=>s(rh());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let c=(e,t)=>{let n=th.find(t=>t.id===e);n&&(Ue(n.hash),s(e),t&&window.requestAnimationFrame(()=>{o.current.get(e)?.focus({preventScroll:!0})}))},l=e=>{let t=th.findIndex(e=>e.id===n),r=null;e.key===`ArrowLeft`?r=(t-1+th.length)%th.length:e.key===`ArrowRight`?r=(t+1)%th.length:e.key===`Home`?r=0:e.key===`End`&&(r=th.length-1),r!==null&&(e.preventDefault(),c(th[r].id,!0))};return(0,z.jsxs)(`section`,{className:`integrations-page`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:t(`nav.integrations`)})}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`integrations.subtitle`)}),(0,z.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":t(`integrations.tabsLabel`),children:th.map(e=>(0,z.jsx)(`button`,{ref:t=>{t?o.current.set(e.id,t):o.current.delete(e.id)},type:`button`,role:`tab`,id:ih(e.id),"aria-selected":n===e.id,"aria-controls":ah(e.id),tabIndex:n===e.id?0:-1,className:`page-tab${n===e.id?` page-tab--active`:``}`,onClick:()=>c(e.id,!0),onKeyDown:l,children:t(e.labelKey)},e.id))}),th.map(t=>{if(!i.has(t.id))return null;let r=n===t.id;return(0,z.jsxs)(`div`,{role:`tabpanel`,id:ah(t.id),"aria-labelledby":ih(t.id),hidden:!r,children:[t.id===`overview`&&(0,z.jsx)(Ym,{apiBase:e,active:r}),t.id===`keys`&&(0,z.jsx)(Hf,{apiBase:e,active:r}),t.id===`codex`&&(0,z.jsx)(Em,{apiBase:e,active:r}),t.id===`claude`&&(0,z.jsx)(Ap,{apiBase:e,active:r}),t.id===`grok`&&(0,z.jsx)(Ip,{apiBase:e,active:r}),nh.has(t.id)&&(0,z.jsx)(eh,{apiBase:e,client:t.id,active:r})]},t.id)})]})}var sh=class e{static Ecc;static encodeText(t,n){let r=dh.makeSegments(t);return e.encodeSegments(r,n)}static encodeBinary(t,n){let r=dh.makeBytes(t);return e.encodeSegments([r],n)}static encodeSegments(t,n,r=1,i=40,a=-1,o=!0){if(!(e.MIN_VERSION<=r&&r<=i&&i<=e.MAX_VERSION)||a<-1||a>7)throw RangeError(`Invalid value`);let s,c;for(s=r;;s++){let r=e.getNumDataCodewords(s,n)*8,a=dh.getTotalBits(t,s);if(a<=r){c=a;break}if(s>=i)throw RangeError(`Data too long`)}for(let t of[e.Ecc.MEDIUM,e.Ecc.QUARTILE,e.Ecc.HIGH])o&&c<=e.getNumDataCodewords(s,t)*8&&(n=t);let l=[];for(let e of t){ch(e.mode.modeBits,4,l),ch(e.numChars,e.mode.numCharCountBits(s),l);for(let t of e.getData())l.push(t)}uh(l.length==c);let u=e.getNumDataCodewords(s,n)*8;uh(l.length<=u),ch(0,Math.min(4,u-l.length),l),ch(0,(8-l.length%8)%8,l),uh(l.length%8==0);for(let e=236;l.length<u;e^=253)ch(e,8,l);let d=[];for(;d.length*8<l.length;)d.push(0);return l.forEach((e,t)=>d[t>>>3]|=e<<7-(t&7)),new e(s,n,d,a)}version;errorCorrectionLevel;size;mask;modules=[];isFunction=[];constructor(t,n,r,i){if(this.version=t,this.errorCorrectionLevel=n,t<e.MIN_VERSION||t>e.MAX_VERSION)throw RangeError(`Version value out of range`);if(i<-1||i>7)throw RangeError(`Mask value out of range`);this.size=t*4+17;let a=[];for(let e=0;e<this.size;e++)a.push(!1);for(let e=0;e<this.size;e++)this.modules.push(a.slice()),this.isFunction.push(a.slice());this.drawFunctionPatterns();let o=this.addEccAndInterleave(r);if(this.drawCodewords(o),i==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(i=t,e=n),this.applyMask(t)}}uh(0<=i&&i<=7),this.mask=i,this.applyMask(i),this.drawFormatBits(i),this.isFunction=[]}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;uh(!(r>>>15));for(let e=0;e<=5;e++)this.setFunctionModule(8,e,lh(r,e));this.setFunctionModule(8,7,lh(r,6)),this.setFunctionModule(8,8,lh(r,7)),this.setFunctionModule(7,8,lh(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,lh(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,lh(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,lh(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;uh(!(t>>>18));for(let e=0;e<18;e++){let n=lh(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(t){let n=this.version,r=this.errorCorrectionLevel;if(t.length!=e.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let i=e.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],a=e.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],o=Math.floor(e.getNumRawDataModules(n)/8),s=i-o%i,c=Math.floor(o/i),l=[],u=e.reedSolomonComputeDivisor(a);for(let n=0,r=0;n<i;n++){let i=t.slice(r,r+c-a+(n<s?0:1));r+=i.length;let o=e.reedSolomonComputeRemainder(i,u);n<s&&i.push(0),l.push(i.concat(o))}let d=[];for(let e=0;e<l[0].length;e++)l.forEach((t,n)=>{(e!=c-a||n>=s)&&d.push(t[e])});return uh(d.length==o),d}drawCodewords(t){if(t.length!=Math.floor(e.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let e=this.size-1;e>=1;e-=2){e==6&&(e=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=e-i,o=e+1&2?r:this.size-1-r;!this.isFunction[o][a]&&n<t.length*8&&(this.modules[o][a]=lh(t[n>>>3],7-(n&7)),n++)}}uh(n==t.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let t=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]===r?(i++,i==5?t+=e.PENALTY_N1:i>5&&t++):(this.finderPenaltyAddHistory(i,a),r||(t+=this.finderPenaltyCountPatterns(a)*e.PENALTY_N3),r=this.modules[n][o],i=1);t+=this.finderPenaltyTerminateAndCount(r,i,a)*e.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]===r?(i++,i==5?t+=e.PENALTY_N1:i>5&&t++):(this.finderPenaltyAddHistory(i,a),r||(t+=this.finderPenaltyCountPatterns(a)*e.PENALTY_N3),r=this.modules[o][n],i=1);t+=this.finderPenaltyTerminateAndCount(r,i,a)*e.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(t+=e.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,i=Math.ceil(Math.abs(n*20-r*10)/r)-1;return uh(0<=i&&i<=9),t+=i*e.PENALTY_N4,uh(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(t){if(t<e.MIN_VERSION||t>e.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*t+128)*t+64;if(t>=2){let e=Math.floor(t/7)+2;n-=(25*e-10)*e-55,t>=7&&(n-=36)}return uh(208<=n&&n<=29648),n}static getNumDataCodewords(t,n){return Math.floor(e.getNumRawDataModules(t)/8)-e.ECC_CODEWORDS_PER_BLOCK[n.ordinal][t]*e.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw RangeError(`Degree out of range`);let n=[];for(let e=0;e<t-1;e++)n.push(0);n.push(1);let r=1;for(let i=0;i<t;i++){for(let t=0;t<n.length;t++)n[t]=e.reedSolomonMultiply(n[t],r),t+1<n.length&&(n[t]^=n[t+1]);r=e.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(t,n){let r=n.map(e=>0);for(let i of t){let t=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=e.reedSolomonMultiply(n,t))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return uh(!(n>>>8)),n}finderPenaltyCountPatterns(e){let t=e[1];uh(t<=this.size*3);let n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}static MIN_VERSION=1;static MAX_VERSION=40;static PENALTY_N1=3;static PENALTY_N2=3;static PENALTY_N3=40;static PENALTY_N4=10;static ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]];static NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]]};function ch(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function lh(e,t){return!!(e>>>t&1)}function uh(e){if(!e)throw Error(`Assertion error`)}var dh=class e{static Mode;static makeBytes(t){let n=[];for(let e of t)ch(e,8,n);return new e(e.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let n=[];for(let e=0;e<t.length;){let r=Math.min(t.length-e,3);ch(parseInt(t.substring(e,e+r),10),r*3+1,n),e+=r}return new e(e.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let n=[],r;for(r=0;r+2<=t.length;r+=2){let i=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r))*45;i+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r+1)),ch(i,11,n)}return r<t.length&&ch(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r)),6,n),new e(e.Mode.ALPHANUMERIC,t.length,n)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let n=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)ch(t,8,n);else if(t<16384)ch(2,2,n),ch(t,14,n);else if(t<1e6)ch(6,3,n),ch(t,21,n);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,n)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}mode;numChars;bitData;constructor(e,t,n){if(this.mode=e,this.numChars=t,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}static NUMERIC_REGEX=/^[0-9]*$/;static ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/;static ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`},fh=class e{static LOW=new e(0,1);static MEDIUM=new e(1,0);static QUARTILE=new e(2,3);static HIGH=new e(3,2);ordinal;formatBits;constructor(e,t){this.ordinal=e,this.formatBits=t}},ph=class e{static NUMERIC=new e(1,[10,12,14]);static ALPHANUMERIC=new e(2,[9,11,13]);static BYTE=new e(4,[8,16,16]);static KANJI=new e(8,[8,10,12]);static ECI=new e(7,[0,0,0]);modeBits;numBitsCharCount;constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};sh.Ecc=fh,dh.Mode=ph;function mh(e,t){let n=[];for(let r=0;r<e.size;r+=1){let i=-1;for(let a=0;a<=e.size;a+=1){if(a<e.size&&e.getModule(a,r)){i===-1&&(i=a);continue}i!==-1&&(n.push(`M${i+t} ${r+t}h${a-i}v1H${i+t}z`),i=-1)}}return n.join(``)}var hh=(0,_.memo)(function({value:e,size:t=220,title:n,className:r}){let i=sh.encodeText(e,sh.Ecc.MEDIUM),a=i.size+8;return(0,z.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 ${a} ${a}`,width:t,height:t,shapeRendering:`crispEdges`,role:`img`,"aria-label":n,className:r,children:[n?(0,z.jsx)(`title`,{children:n}):null,(0,z.jsx)(`rect`,{width:a,height:a,fill:`#fff`}),(0,z.jsx)(`path`,{d:mh(i,4),fill:`#111`})]})}),gh=new Set([`dashboard`,`startup`,`providers`,`models`,`subagents`,`logs`,`desktop-logs`,`usage`,`storage`,`codex-auth`,`integrations`,`android-remote`,`guide`]),_h=`android-remote/pair`;function vh(e){let t=Ve(e??(typeof window<`u`?window.location.hash:``)).split(`/`)[0];return t===`debug`?`logs`:t===`combos`||t===`routing`?`models`:t===`api`||t===`claude`||t===`grok`?`integrations`:gh.has(t)?t:`dashboard`}var yh=[`dashboard/providers`,`dashboard/models`],bh=[`models/combos`,`models/routing`],xh=[`integrations/keys`,`integrations/codex`,`integrations/claude`,`integrations/claude/desktop`,`integrations/grok`,`integrations/opencode`,`integrations/pi`,`integrations/omp`,`integrations/hermes`,`integrations/openclaw`,`integrations/kimi`,`integrations/gajae`];function Sh(e,t){return e===t||t===`android-remote`&&e===`android-remote/pair`||t===`logs`&&e===`logs/debug`||t===`models`&&bh.includes(e)||t===`dashboard`&&(e===`dashboard/update`||yh.includes(e))||t===`integrations`&&xh.includes(e)}function Ch(e){let t=vh(e);return e===`debug`||e.startsWith(`debug/`)?{page:`logs`,replaceTo:`logs/debug`}:e===`combos`||e.startsWith(`combos/`)?{page:`models`,replaceTo:`models/combos`}:e===`routing`||e.startsWith(`routing/`)?{page:`models`,replaceTo:`models/routing`}:e===`api`?{page:`integrations`,replaceTo:`integrations/keys`}:e===`claude`?{page:`integrations`,replaceTo:`integrations/claude`}:e===`grok`?{page:`integrations`,replaceTo:`integrations/grok`}:e===`providers/workspace`?{page:`providers`,replaceTo:`providers`}:Sh(e,t)?{page:t,replaceTo:null}:{page:t,replaceTo:t}}function wh(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Th(e){return e===void 0||typeof e==`string`}function Eh(e){return wh(e)?typeof e.id==`string`&&typeof e.label==`string`&&e.deviceType===`mobile`&&typeof e.os==`string`&&Th(e.address)&&Array.isArray(e.scopes)&&e.scopes.every(e=>typeof e==`string`)&&typeof e.createdAt==`string`&&Th(e.lastSeenAt)&&typeof e.online==`boolean`:!1}function Dh(e){return!wh(e)||!wh(e.configuration)||!wh(e.runtime)?!1:[`quick`,`named`].includes(String(e.configuration.mode))&&Th(e.configuration.namedHostname)&&typeof e.configuration.hasNamedTunnelToken==`boolean`&&[`quick`,`named`].includes(String(e.runtime.mode))&&[`stopped`,`starting`,`checking`,`ready`,`error`].includes(String(e.runtime.status))&&(e.runtime.publicUrl===null||typeof e.runtime.publicUrl==`string`)&&(e.runtime.error===null||[`cloudflared_unavailable`,`named_tunnel_incomplete`,`tunnel_failed`,`verification_failed`].includes(String(e.runtime.error)))}function Oh(e){return!wh(e)||!wh(e.gateway)||!wh(e.desktop)?!1:e.version===1&&typeof e.controlEnabled==`boolean`&&typeof e.keepAwake==`boolean`&&typeof e.pairingAvailable==`boolean`&&[`stopped`,`starting`,`ready`,`error`].includes(String(e.gateway.status))&&e.gateway.backgroundServer===`current-process`&&typeof e.gateway.port==`number`&&Number.isInteger(e.gateway.port)&&Th(e.gateway.error)&&Array.isArray(e.reachableAddresses)&&e.reachableAddresses.every(e=>typeof e==`string`)&&Dh(e.tunnel)&&e.desktop.id===`desktop`&&typeof e.desktop.label==`string`&&typeof e.desktop.platform==`string`&&typeof e.desktop.address==`string`&&e.desktop.online===!0&&Array.isArray(e.clients)&&e.clients.every(Eh)}function kh(e){return wh(e)&&e.version===1&&typeof e.id==`string`&&typeof e.expiresAt==`string`&&Number.isFinite(Date.parse(e.expiresAt))&&typeof e.qrPayload==`string`&&e.qrPayload.length>0}function Ah(e){return wh(e)&&typeof e.id==`string`&&typeof e.name==`string`}function jh(e){return wh(e)&&typeof e.id==`string`&&typeof e.name==`string`&&typeof e.accountId==`string`&&typeof e.accountName==`string`&&[`active`,`pending`,`initializing`,`moved`,`deactivated`,`unknown`].includes(String(e.status))&&Array.isArray(e.nameServers)&&e.nameServers.every(e=>typeof e==`string`)}function Mh(e){return wh(e)&&e.version===1&&Array.isArray(e.accounts)&&e.accounts.every(Ah)&&Array.isArray(e.zones)&&e.zones.every(jh)}async function Nh(e){let t=await ct(e);if(!Oh(t))throw Error(`invalid Android Remote response`);return t}function Ph(e){return`android-remote:${e}`}async function Fh(e,t){return Nh(await fetch(`${e}/api/android-remote`,{signal:t}))}async function Ih(e,t){return Nh(await fetch(`${e}/api/android-remote/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}))}async function Lh(e,t){return Nh(await fetch(`${e}/api/android-remote/tunnel`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}))}async function Rh(e,t){let n=await ct(await fetch(`${e}/api/android-remote/cloudflare/discover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({apiToken:t})}));if(!Mh(n))throw Error(`invalid Cloudflare discovery response`);return n}async function zh(e,t){return Nh(await fetch(`${e}/api/android-remote/cloudflare/provision`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}))}async function Bh(e){return Nh(await fetch(`${e}/api/android-remote/tunnel/retry`,{method:`POST`}))}async function Vh(e){return Nh(await fetch(`${e}/api/android-remote/tunnel/token`,{method:`DELETE`}))}async function Hh(e){return Nh(await fetch(`${e}/api/android-remote/tunnel/domain`,{method:`DELETE`}))}async function Uh(e,t){return Nh(await fetch(`${e}/api/android-remote/clients/${encodeURIComponent(t)}`,{method:`DELETE`}))}async function Wh(e){let t=await ct(await fetch(`${e}/api/android-remote/pairing`,{method:`POST`}));if(!kh(t))throw Error(`invalid Android Remote pairing response`);return t}function Gh(e=globalThis.crypto){let t=e.getRandomValues(new Uint8Array(5));return`rmx-${Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}`}function Kh({apiBase:e,status:t,onClose:n}){let r=(0,_.useRef)(null),{t:i}=Z(),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(0),p=(0,_.useCallback)(async()=>{if(t.pairingAvailable){c(!0),u(!1),o(null),f(Date.now());try{let t=await Wh(e);o(t),f(Date.now())}catch{o(null),u(!0)}finally{c(!1)}}},[e,t.pairingAvailable]);(0,_.useEffect)(()=>{let e=r.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]),(0,_.useEffect)(()=>{let e=window.setTimeout(()=>void p(),0);return()=>window.clearTimeout(e)},[p]),(0,_.useEffect)(()=>{if(!a)return;let e=window.setInterval(()=>f(Date.now()),1e3);return()=>window.clearInterval(e)},[a]);let m=a?Math.max(0,Math.ceil((Date.parse(a.expiresAt)-d)/1e3)):0,h=!!a&&m===0,g=`${Math.floor(m/60)}:${String(m%60).padStart(2,`0`)}`;return(0,z.jsxs)(`dialog`,{ref:r,className:`modal-overlay`,"aria-labelledby":`android-remote-pairing-title`,"aria-describedby":`android-remote-pairing-desc`,onCancel:e=>{e.preventDefault(),n()},children:[(0,z.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":i(`common.close`),tabIndex:-1,onClick:n}),(0,z.jsxs)(`div`,{className:`modal-card android-remote-dialog`,role:`document`,children:[(0,z.jsxs)(`div`,{className:`modal-head`,children:[(0,z.jsxs)(`div`,{className:`android-remote-dialog-title`,children:[(0,z.jsx)(`span`,{className:`android-remote-dialog-icon`,"aria-hidden":`true`,children:(0,z.jsx)(Ce,{})}),(0,z.jsx)(`h3`,{id:`android-remote-pairing-title`,children:i(`remote.dialog.title`)})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon`,onClick:n,"aria-label":i(`common.close`),children:(0,z.jsx)(Y,{})})]}),(0,z.jsx)(`p`,{id:`android-remote-pairing-desc`,className:`modal-desc`,children:i(`remote.dialog.description`)}),!t.pairingAvailable&&(0,z.jsxs)(`div`,{className:`android-remote-readiness`,role:`status`,children:[(0,z.jsxs)(`div`,{className:`android-remote-readiness-row ready`,children:[(0,z.jsx)(J,{"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.dialog.dashboardReady`)}),(0,z.jsx)(`span`,{children:i(`remote.dialog.dashboardReadyHint`)})]})]}),(0,z.jsxs)(`div`,{className:`android-remote-readiness-row pending`,children:[(0,z.jsx)(he,{"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(t.gateway.status===`error`?`remote.dialog.gatewayError`:`remote.dialog.gatewayPending`)}),(0,z.jsx)(`span`,{children:i(t.gateway.status===`starting`?`remote.dialog.gatewayStartingHint`:t.gateway.status===`error`?`remote.dialog.gatewayErrorHint`:`remote.dialog.gatewayPendingHint`)})]})]}),(0,z.jsxs)(`div`,{className:`android-remote-readiness-row pending`,children:[(0,z.jsx)(Ce,{"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.dialog.enableControl`)}),(0,z.jsx)(`span`,{children:i(`remote.dialog.enableControlHint`)})]})]})]}),t.pairingAvailable&&s&&!a&&(0,z.jsxs)(`div`,{className:`android-remote-pairing-state`,role:`status`,children:[(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:i(`remote.dialog.creatingCode`)})]}),t.pairingAvailable&&l&&!s&&(0,z.jsxs)(`div`,{className:`android-remote-pairing-failure`,children:[(0,z.jsx)($,{tone:`err`,children:i(`remote.dialog.codeError`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void p(),children:[(0,z.jsx)(X,{}),` `,i(`common.retry`)]})]}),t.pairingAvailable&&a&&!h&&(0,z.jsxs)(`div`,{className:`android-remote-pairing`,children:[(0,z.jsx)(`div`,{className:`android-remote-qr-frame`,children:(0,z.jsx)(hh,{value:a.qrPayload,title:i(`remote.dialog.qrTitle`)})}),(0,z.jsxs)(`div`,{className:`android-remote-pairing-copy`,children:[(0,z.jsx)(`strong`,{children:i(`remote.dialog.scanTitle`)}),(0,z.jsx)(`span`,{children:i(`remote.dialog.scanHint`)}),(0,z.jsxs)(`div`,{className:`android-remote-pairing-meta`,children:[(0,z.jsx)(`span`,{className:`android-remote-pairing-expiry`,role:`timer`,children:i(`remote.dialog.expiresIn`,{value:g})}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void p(),disabled:s,"aria-label":i(`remote.dialog.refreshCode`),children:[(0,z.jsx)(X,{"aria-hidden":`true`}),` `,i(`remote.dialog.refreshCode`)]})]})]})]}),t.pairingAvailable&&a&&h&&(0,z.jsxs)(`div`,{className:`android-remote-pairing-failure`,children:[(0,z.jsx)($,{tone:`warn`,children:i(`remote.dialog.codeExpired`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>void p(),children:[(0,z.jsx)(X,{}),` `,i(`remote.dialog.newCode`)]})]}),(0,z.jsx)(`div`,{className:`modal-actions android-remote-dialog-actions`,children:(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:n,children:i(`common.close`)})})]})]})}function qh(e,t){return t(e===`ready`?`remote.gatewayReady`:e===`starting`?`remote.gatewayStarting`:e===`error`?`remote.gatewayError`:`remote.gatewayStopped`)}function Jh(e,t){return t(e===`ready`?`remote.tunnel.statusReady`:e===`starting`?`remote.tunnel.statusStarting`:e===`checking`?`remote.tunnel.statusChecking`:e===`error`?`remote.tunnel.statusFailed`:`remote.tunnel.statusStopped`)}function Yh({state:e,children:t}){return(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-progress-row ${e}`,"aria-current":e===`active`?`step`:void 0,children:[e===`complete`&&(0,z.jsx)(J,{"aria-hidden":`true`}),e===`active`&&(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}),e===`failed`&&(0,z.jsx)(Y,{"aria-hidden":`true`}),e===`pending`&&(0,z.jsx)(`span`,{className:`android-remote-progress-dot`,"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t})]})}function Xh({apiBase:e,status:t,onPublish:n,onError:r}){let{t:i}=Z(),[a,o]=(0,_.useState)(t.tunnel.configuration.mode),[s,c]=(0,_.useState)(t.tunnel.configuration.namedHostname??``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(null),[h,g]=(0,_.useState)(``),[v,y]=(0,_.useState)(``),[b,x]=(0,_.useState)(Gh),[S,C]=(0,_.useState)(!0),[w,T]=(0,_.useState)(null),[E,D]=(0,_.useState)(!1),[O,k]=(0,_.useState)(null),A=(0,_.useRef)(null),j=`${t.tunnel.configuration.mode}:${t.tunnel.configuration.namedHostname??``}`,M=(0,_.useRef)(j);(0,_.useEffect)(()=>{M.current!==j&&(M.current=j,o(t.tunnel.configuration.mode),c(t.tunnel.configuration.namedHostname??``))},[j,t.tunnel.configuration.mode,t.tunnel.configuration.namedHostname]);let N=e=>{T(e instanceof Error?e.message:i(`remote.tunnel.automaticError`))},P=async()=>{o(`quick`),k(`quick`),T(null);try{n(await Lh(e,{mode:`quick`}))}catch(e){o(t.tunnel.configuration.mode),N(e)}finally{k(null)}},F=async()=>{k(`manual`),T(null);try{let t=await Lh(e,{mode:`named`,hostname:s,...l.trim()?{token:l.trim()}:{}});u(``),n(t)}catch(e){N(e)}finally{k(null)}},I=async()=>{k(`discover`),T(null),D(!1);try{let t=await Rh(e,d.trim());m(t);let n=t.accounts[0]?.id??``;g(n),y(t.zones.find(e=>e.accountId===n)?.id??``)}catch(e){m(null),g(``),y(``),N(e)}finally{k(null)}},L=p?.zones.filter(e=>e.accountId===h)??[],R=L.find(e=>e.id===v)??null,B=async()=>{if(R){k(`provision`),T(null),D(!1);try{let t=await zh(e,{apiToken:d.trim(),accountId:h,zoneId:R.id,hostname:`${b.trim().toLowerCase()}.${R.name}`});f(``),m(null),D(!0),n(t)}catch(e){N(e)}finally{k(null)}}},V=async()=>{k(`retry`);try{n(await Bh(e))}catch{r()}finally{k(null)}},H=async()=>{k(`remove`);try{u(``),n(await Vh(e))}catch{r()}finally{k(null)}},U=()=>{f(``),m(null),g(``),y(``),D(!1),x(Gh()),T(null),C(!1),window.setTimeout(()=>A.current?.focus(),0)},W=async()=>{k(`disconnect`),T(null);try{let t=await Hh(e);f(``),m(null),g(``),y(``),D(!1),c(``),o(`quick`),n(t)}catch(e){N(e)}finally{k(null)}},G=t.tunnel.runtime,ee=G.status===`checking`||G.status===`ready`||G.status===`error`&&G.error===`verification_failed`?`complete`:G.status===`starting`?`active`:G.status===`error`?`failed`:`pending`,te=G.status===`ready`?`complete`:G.status===`checking`?`active`:G.status===`error`&&G.error===`verification_failed`?`failed`:`pending`,K=G.error===`cloudflared_unavailable`?`remote.tunnel.errorCloudflared`:G.error===`named_tunnel_incomplete`?`remote.tunnel.errorIncomplete`:G.error===`verification_failed`?`remote.tunnel.errorVerification`:`remote.tunnel.errorFailed`;return(0,z.jsxs)(`section`,{className:`android-remote-section`,"aria-labelledby":`android-remote-tunnel-heading`,children:[(0,z.jsxs)(`div`,{className:`android-remote-section-heading`,children:[(0,z.jsx)(Se,{"aria-hidden":`true`}),(0,z.jsx)(`h3`,{id:`android-remote-tunnel-heading`,children:i(`remote.tunnel.heading`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-card`,children:[(0,z.jsxs)(`div`,{className:`android-remote-tunnel-intro`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.title`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.hint`)})]}),(0,z.jsx)(`span`,{className:`android-remote-gateway-badge ${G.status}`,role:`status`,children:Jh(G.status,i)})]}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-options`,role:`radiogroup`,"aria-label":i(`remote.tunnel.modeLabel`),children:[(0,z.jsxs)(`label`,{className:`android-remote-tunnel-option ${a===`quick`?`selected`:``}`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`android-tunnel-mode`,value:`quick`,checked:a===`quick`,disabled:O!==null,onChange:()=>{t.tunnel.configuration.mode===`quick`?o(`quick`):P()}}),(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`span`,{className:`android-remote-tunnel-option-title`,children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.quickTitle`)}),(0,z.jsx)(`em`,{children:i(`remote.tunnel.quickBadge`)})]}),(0,z.jsx)(`small`,{children:i(`remote.tunnel.quickHint`)})]})]}),(0,z.jsxs)(`label`,{className:`android-remote-tunnel-option ${a===`named`?`selected`:``}`,children:[(0,z.jsx)(`input`,{type:`radio`,name:`android-tunnel-mode`,value:`named`,checked:a===`named`,disabled:O!==null,onChange:()=>o(`named`)}),(0,z.jsxs)(`span`,{children:[(0,z.jsxs)(`span`,{className:`android-remote-tunnel-option-title`,children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.namedTitle`)}),(0,z.jsx)(`em`,{children:i(`remote.tunnel.namedBadge`)})]}),(0,z.jsx)(`small`,{children:i(`remote.tunnel.namedHint`)})]})]})]}),(0,z.jsxs)(`details`,{className:`android-remote-tunnel-compare`,children:[(0,z.jsx)(`summary`,{children:i(`remote.tunnel.compareTitle`)}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-compare-grid`,children:[(0,z.jsxs)(`article`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.quickTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.compareQuickBest`)}),(0,z.jsxs)(`ul`,{children:[(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareQuickSetup`)}),(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareQuickAddress`)}),(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareQuickLimit`)})]})]}),(0,z.jsxs)(`article`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.namedTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.compareNamedBest`)}),(0,z.jsxs)(`ul`,{children:[(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareNamedAddress`)}),(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareNamedSetup`)}),(0,z.jsx)(`li`,{children:i(`remote.tunnel.compareNamedTime`)})]})]})]}),(0,z.jsx)(`p`,{className:`android-remote-tunnel-compare-shared`,children:i(`remote.tunnel.compareShared`)})]}),a===`named`&&(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-wizard`,children:[(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-wizard-copy`,children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.automaticTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.automaticHint`)})]}),(0,z.jsxs)(`details`,{className:`android-remote-cloudflare-token-guide`,open:S,onToggle:e=>C(e.currentTarget.open),children:[(0,z.jsx)(`summary`,{children:(0,z.jsxs)(`span`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenGuideTitle`)}),(0,z.jsx)(`small`,{children:i(`remote.tunnel.tokenGuideHint`)})]})}),(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-token-guide-body`,children:[(0,z.jsx)(`a`,{className:`btn btn-ghost`,href:`https://dash.cloudflare.com/profile/api-tokens`,target:`_blank`,rel:`noreferrer`,children:i(`remote.tunnel.createApiToken`)}),(0,z.jsxs)(`ol`,{children:[(0,z.jsx)(`li`,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenStepCustomTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.tokenStepCustomBody`)})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenStepPermissionsTitle`)}),(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-permission-list`,role:`list`,children:[(0,z.jsx)(`code`,{role:`listitem`,children:i(`remote.tunnel.tokenPermissionTunnel`)}),(0,z.jsx)(`code`,{role:`listitem`,children:i(`remote.tunnel.tokenPermissionDns`)}),(0,z.jsx)(`code`,{role:`listitem`,children:i(`remote.tunnel.tokenPermissionZone`)})]})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenStepResourcesTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.tokenStepResourcesBody`)})]})}),(0,z.jsx)(`li`,{children:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.tokenStepCopyTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.tokenStepCopyBody`)})]})})]}),(0,z.jsx)(`p`,{className:`android-remote-cloudflare-token-guide-finish`,children:i(`remote.tunnel.tokenGuideFinish`)})]})]}),(0,z.jsxs)(`label`,{className:`android-remote-cloudflare-field`,children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.apiTokenLabel`)}),(0,z.jsx)(`input`,{ref:A,type:`password`,value:d,onChange:e=>{f(e.target.value),m(null),g(``),y(``),D(!1)},placeholder:i(`remote.tunnel.apiTokenPlaceholder`),autoComplete:`off`,spellCheck:!1})]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost android-remote-cloudflare-authorize`,disabled:O!==null||!d.trim(),onClick:()=>void I(),children:[O===`discover`?(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}):(0,z.jsx)(Se,{"aria-hidden":`true`}),i(O===`discover`?`remote.tunnel.authorizing`:p?`remote.tunnel.refreshDomains`:`remote.tunnel.authorize`)]}),p&&(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-selection`,children:[(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-progress-row complete`,children:[(0,z.jsx)(J,{"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:i(`remote.tunnel.authorized`)})]}),p.accounts.length===0||p.zones.length===0?(0,z.jsx)($,{tone:`warn`,children:i(`remote.tunnel.noDomains`)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`android-remote-tunnel-form`,children:[(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.accountLabel`)}),(0,z.jsx)(`select`,{value:h,onChange:e=>{let t=e.target.value;g(t),y(p.zones.find(e=>e.accountId===t)?.id??``)},children:p.accounts.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.domainLabel`)}),(0,z.jsx)(`select`,{value:v,onChange:e=>y(e.target.value),children:L.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))})]})]}),R&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{className:`android-remote-cloudflare-field`,children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.subdomainLabel`)}),(0,z.jsxs)(`div`,{className:`android-remote-subdomain-input`,children:[(0,z.jsx)(`input`,{value:b,onChange:e=>x(e.target.value),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1}),(0,z.jsxs)(`span`,{children:[`.`,R.name]})]}),(0,z.jsx)(`small`,{children:i(`remote.tunnel.subdomainSecurityHint`)})]}),R.status!==`active`&&(0,z.jsxs)($,{tone:`warn`,children:[i(`remote.tunnel.domainPending`),R.nameServers.length>0&&(0,z.jsx)(`span`,{className:`android-remote-name-servers`,children:R.nameServers.map(e=>(0,z.jsx)(`code`,{children:e},e))})]}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-primary android-remote-cloudflare-connect`,disabled:O!==null||R.status!==`active`||!b.trim(),onClick:()=>void B(),children:[O===`provision`?(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}):(0,z.jsx)(J,{"aria-hidden":`true`}),i(O===`provision`?`remote.tunnel.connecting`:`remote.tunnel.connect`)]})]})]})]}),E&&(0,z.jsxs)(`div`,{className:`android-remote-cloudflare-progress`,"aria-label":i(`remote.tunnel.progressLabel`),"aria-live":`polite`,children:[(0,z.jsx)(Yh,{state:`complete`,children:i(`remote.tunnel.resourcesConfigured`)}),(0,z.jsx)(Yh,{state:ee,children:i(`remote.tunnel.connectorAccepted`)}),(0,z.jsx)(Yh,{state:te,children:i(`remote.tunnel.gatewayVerified`)})]}),(0,z.jsxs)(`details`,{className:`android-remote-tunnel-guide android-remote-manual-setup`,children:[(0,z.jsx)(`summary`,{children:i(`remote.tunnel.manualTitle`)}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.manualHint`)}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-form`,children:[(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.hostnameLabel`)}),(0,z.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`codex.example.com`,autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,z.jsxs)(`label`,{children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.tokenLabel`)}),(0,z.jsx)(`input`,{type:`password`,value:l,onChange:e=>u(e.target.value),placeholder:t.tunnel.configuration.hasNamedTunnelToken?i(`remote.tunnel.tokenSavedPlaceholder`):i(`remote.tunnel.tokenPlaceholder`),autoComplete:`off`})]})]}),(0,z.jsxs)(`div`,{className:`android-remote-tunnel-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:O!==null||!s.trim(),onClick:()=>void F(),children:i(O===`manual`?`remote.tunnel.saving`:`remote.tunnel.manualSave`)}),t.tunnel.configuration.hasNamedTunnelToken&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:O!==null,onClick:()=>void H(),children:i(`remote.tunnel.removeToken`)})]}),(0,z.jsx)(`p`,{className:`android-remote-tunnel-guide-note`,children:i(`remote.tunnel.manualOrigin`)})]})]}),G.mode===a&&G.status===`ready`&&G.publicUrl&&(0,z.jsxs)(`div`,{className:`android-remote-tunnel-url`,children:[(0,z.jsx)(`span`,{children:i(`remote.tunnel.verifiedUrl`)}),(0,z.jsx)(`code`,{children:G.publicUrl})]}),t.tunnel.configuration.mode===`named`&&t.tunnel.configuration.namedHostname&&(0,z.jsxs)(`div`,{className:`android-remote-domain-management`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:i(`remote.tunnel.domainManagementTitle`)}),(0,z.jsx)(`code`,{children:t.tunnel.configuration.namedHostname}),(0,z.jsx)(`p`,{children:i(`remote.tunnel.domainManagementHint`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-domain-management-actions`,children:[(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:O!==null,onClick:U,children:i(`remote.tunnel.changeDomain`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-danger`,disabled:O!==null,onClick:()=>void W(),children:[O===`disconnect`?(0,z.jsx)(X,{className:`spin-icon`,"aria-hidden":`true`}):(0,z.jsx)(Y,{"aria-hidden":`true`}),i(O===`disconnect`?`remote.tunnel.disconnectingDomain`:`remote.tunnel.disconnectDomain`)]})]})]}),w&&(0,z.jsx)($,{tone:`err`,children:w}),G.status===`error`&&G.error&&(0,z.jsx)($,{tone:`err`,children:i(K)}),(0,z.jsx)(`div`,{className:`android-remote-tunnel-actions`,children:(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:O!==null||!t.controlEnabled,onClick:()=>void V(),children:[(0,z.jsx)(X,{}),` `,i(O===`retry`?`remote.tunnel.retrying`:`common.retry`)]})})]})]})}function Zh({client:e,busy:t,onRevoke:n}){let{t:r,locale:i}=Z(),a=e.lastSeenAt?new Date(e.lastSeenAt).toLocaleString(i):r(`remote.neverSeen`);return(0,z.jsxs)(`div`,{className:`android-remote-client-row`,children:[(0,z.jsxs)(`div`,{className:`android-remote-client-main`,children:[(0,z.jsx)(`span`,{className:`android-remote-status-dot ${e.online?`online`:`offline`}`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`android-remote-client-copy`,children:[(0,z.jsxs)(`div`,{className:`android-remote-client-name`,children:[(0,z.jsx)(`strong`,{children:e.label}),(0,z.jsx)(`span`,{className:`android-remote-state-label`,children:r(e.online?`remote.online`:`remote.offline`)})]}),(0,z.jsx)(`span`,{children:r(`remote.mobileMeta`,{os:e.os,address:e.address??r(`remote.unknownAddress`),count:e.scopes.length})}),(0,z.jsx)(`span`,{children:r(`remote.lastSeen`,{value:a})}),e.scopes.length>0&&(0,z.jsx)(`div`,{className:`android-remote-scopes`,"aria-label":r(`remote.permissions`),children:e.scopes.map(e=>(0,z.jsx)(`code`,{children:e},e))})]})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:n,disabled:t,children:r(t?`remote.revoking`:`remote.revoke`)})]})}function Qh({apiBase:e}){let{t}=Z(),n=Ph(e),r=bs(n,[e],t=>Fh(e,t),{isEmpty:()=>!1,pollMs:5e3}),{state:i}=r,a=i.data,[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)(()=>Ve(window.location.hash)===_h),m=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=()=>{Ve(window.location.hash)===`android-remote/pair`&&p(!0)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let h=e=>{L(n,e),d(!1)},g=async(t,n)=>{s(t),d(!1);try{h(await Ih(e,{[t]:n}))}catch{d(!0)}finally{s(null)}},v=async n=>{if(window.confirm(t(`remote.revokeConfirm`,{name:n.label}))){l(n.id),d(!1);try{h(await Uh(e,n.id))}catch{d(!0)}finally{l(null)}}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head android-remote-page-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{children:t(`remote.title`)}),(0,z.jsx)(`p`,{className:`page-sub`,children:t(`remote.subtitle`)})]}),(0,z.jsxs)(`button`,{ref:m,type:`button`,className:`btn btn-primary android-remote-add`,onClick:()=>p(!0),"aria-haspopup":`dialog`,children:[(0,z.jsx)(ne,{}),` `,t(`remote.addPhone`)]})]}),i.showSkeleton&&!a?(0,z.jsx)(Ss,{label:t(`remote.loading`),rows:5}):i.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`android-remote-error`,children:[(0,z.jsx)($,{tone:`err`,children:t(`remote.loadError`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>r.refresh(),children:t(`common.retry`)})]}):a?(0,z.jsxs)(`div`,{className:`android-remote-page`,"aria-busy":o!==null||c!==null||void 0,children:[i.refreshing&&(0,z.jsx)(Cs,{className:`android-remote-refresh-status`,live:!i.showError,children:t(`remote.refreshing`)}),i.showError&&(0,z.jsx)($,{tone:`err`,children:t(`remote.staleError`)}),u&&(0,z.jsx)($,{tone:`err`,children:t(`remote.saveError`)}),(0,z.jsxs)(`section`,{className:`android-remote-section`,"aria-labelledby":`android-remote-settings-heading`,children:[(0,z.jsxs)(`div`,{className:`android-remote-section-heading`,children:[(0,z.jsx)(Ce,{"aria-hidden":`true`}),(0,z.jsx)(`h3`,{id:`android-remote-settings-heading`,children:t(`remote.settingsHeading`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-settings-card`,children:[(0,z.jsxs)(`div`,{className:`android-remote-setting-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:t(`remote.controlTitle`)}),(0,z.jsx)(`p`,{children:t(`remote.controlHint`)}),(0,z.jsx)(`div`,{className:`android-remote-addresses`,children:a.reachableAddresses.map(e=>(0,z.jsx)(`code`,{children:e},e))})]}),(0,z.jsx)(tt,{on:a.controlEnabled,onClick:()=>void g(`controlEnabled`,!a.controlEnabled),disabled:o!==null,label:t(`remote.controlTitle`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-setting-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:t(`remote.keepAwakeTitle`)}),(0,z.jsx)(`p`,{children:t(`remote.keepAwakeHint`)})]}),(0,z.jsx)(tt,{on:a.keepAwake,onClick:()=>void g(`keepAwake`,!a.keepAwake),disabled:o!==null||!a.controlEnabled,label:t(`remote.keepAwakeTitle`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-setting-row android-remote-gateway-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:t(`remote.backgroundTitle`)}),(0,z.jsx)(`p`,{children:t(`remote.backgroundHint`)})]}),(0,z.jsx)(`span`,{className:`android-remote-gateway-badge ${a.gateway.status}`,children:qh(a.gateway.status,t)})]})]})]}),(0,z.jsx)(Xh,{apiBase:e,status:a,onPublish:h,onError:()=>d(!0)}),(0,z.jsxs)(`section`,{className:`android-remote-section`,"aria-labelledby":`android-remote-clients-heading`,children:[(0,z.jsxs)(`div`,{className:`android-remote-section-heading`,children:[(0,z.jsx)(he,{"aria-hidden":`true`}),(0,z.jsx)(`h3`,{id:`android-remote-clients-heading`,children:t(`remote.clientsHeading`)})]}),(0,z.jsxs)(`div`,{className:`android-remote-clients-card`,children:[(0,z.jsx)(`div`,{className:`android-remote-client-row desktop`,children:(0,z.jsxs)(`div`,{className:`android-remote-client-main`,children:[(0,z.jsx)(`span`,{className:`android-remote-status-dot online`,"aria-hidden":`true`}),(0,z.jsxs)(`div`,{className:`android-remote-client-copy`,children:[(0,z.jsxs)(`div`,{className:`android-remote-client-name`,children:[(0,z.jsx)(`strong`,{children:a.desktop.label}),(0,z.jsx)(`span`,{className:`android-remote-this-device`,children:t(`remote.thisDevice`)})]}),(0,z.jsx)(`span`,{children:t(`remote.desktopMeta`,{platform:a.desktop.platform,address:a.desktop.address})})]})]})}),a.clients.map(e=>(0,z.jsx)(Zh,{client:e,busy:c===e.id,onRevoke:()=>void v(e)},e.id)),a.clients.length===0&&(0,z.jsxs)(`div`,{className:`android-remote-empty-clients`,children:[(0,z.jsx)(Ce,{"aria-hidden":`true`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:t(`remote.noPhones`)}),(0,z.jsx)(`span`,{children:t(`remote.noPhonesHint`)})]})]})]})]})]}):null,f&&a&&(0,z.jsx)(Kh,{apiBase:e,status:a,onClose:()=>{p(!1),Ve(window.location.hash)===`android-remote/pair`&&He(`android-remote`),window.setTimeout(()=>m.current?.focus(),0)}})]})}var $h=`ocx-guide-audience`;function eg(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function tg(e=eg()){try{return e?.getItem(`ocx-guide-audience`)===`advanced`?`advanced`:`beginner`}catch{return`beginner`}}function ng(e,t=eg()){try{t?.setItem($h,e)}catch{}}var rg=[{id:`dashboard`,labelKey:`nav.dashboard`,beginnerKey:`guide.section.dashboard.beginner`,advancedKey:`guide.section.dashboard.advanced`,includesKey:`guide.section.dashboard.includes`,target:`dashboard`,Icon:V},{id:`codex-auth`,labelKey:`nav.codexAuth`,beginnerKey:`guide.section.codexAuth.beginner`,advancedKey:`guide.section.codexAuth.advanced`,includesKey:`guide.section.codexAuth.includes`,target:`codex-auth`,Icon:he},{id:`providers`,labelKey:`nav.providers`,beginnerKey:`guide.section.providers.beginner`,advancedKey:`guide.section.providers.advanced`,includesKey:`guide.section.providers.includes`,target:`providers`,Icon:H},{id:`models`,labelKey:`nav.models`,beginnerKey:`guide.section.models.beginner`,advancedKey:`guide.section.models.advanced`,includesKey:`guide.section.models.includes`,target:`models`,Icon:U},{id:`subagents`,labelKey:`nav.subagents`,beginnerKey:`guide.section.subagents.beginner`,advancedKey:`guide.section.subagents.advanced`,includesKey:`guide.section.subagents.includes`,target:`subagents`,Icon:W},{id:`logs`,labelKey:`nav.logs`,beginnerKey:`guide.section.logs.beginner`,advancedKey:`guide.section.logs.advanced`,includesKey:`guide.section.logs.includes`,target:`logs`,Icon:G},{id:`usage`,labelKey:`nav.usage`,beginnerKey:`guide.section.usage.beginner`,advancedKey:`guide.section.usage.advanced`,includesKey:`guide.section.usage.includes`,target:`usage`,Icon:K},{id:`storage`,labelKey:`nav.storage`,beginnerKey:`guide.section.storage.beginner`,advancedKey:`guide.section.storage.advanced`,includesKey:`guide.section.storage.includes`,target:`storage`,Icon:q},{id:`integrations`,labelKey:`nav.integrations`,beginnerKey:`guide.section.integrations.beginner`,advancedKey:`guide.section.integrations.advanced`,includesKey:`guide.section.integrations.includes`,target:`integrations`,Icon:Se},{id:`android-remote`,labelKey:`nav.androidRemote`,beginnerKey:`guide.section.androidRemote.beginner`,advancedKey:`guide.section.androidRemote.advanced`,includesKey:`guide.section.androidRemote.includes`,target:`android-remote`,Icon:Ce},{id:`startup`,labelKey:`nav.startup`,beginnerKey:`guide.section.startup.beginner`,advancedKey:`guide.section.startup.advanced`,includesKey:`guide.section.startup.includes`,target:`startup`,Icon:pe},{id:`sidebar`,labelKey:`guide.section.sidebar.title`,beginnerKey:`guide.section.sidebar.beginner`,advancedKey:`guide.section.sidebar.advanced`,includesKey:`guide.section.sidebar.includes`,Icon:xe}],ig=[`connect`,`models`,`clients`];function ag(){let e=Q(),[t,n]=(0,_.useState)(tg),r=e=>{n(e),ng(e)};return(0,z.jsxs)(`section`,{className:`guide-page`,children:[(0,z.jsx)(`div`,{className:`page-head`,children:(0,z.jsx)(`h2`,{children:e(`guide.title`)})}),(0,z.jsx)(`p`,{className:`page-sub`,children:e(`guide.subtitle`)}),(0,z.jsxs)(`section`,{className:`guide-audience`,"aria-labelledby":`guide-audience-title`,children:[(0,z.jsxs)(`div`,{className:`guide-audience-copy`,children:[(0,z.jsx)(`span`,{className:`guide-eyebrow`,children:e(`guide.mode.label`)}),(0,z.jsx)(`h3`,{id:`guide-audience-title`,children:e(t===`beginner`?`guide.mode.beginnerTitle`:`guide.mode.advancedTitle`)}),(0,z.jsx)(`p`,{children:e(t===`beginner`?`guide.mode.beginnerDescription`:`guide.mode.advancedDescription`)})]}),(0,z.jsx)(`div`,{className:`guide-mode-switch`,role:`group`,"aria-label":e(`guide.mode.label`),children:[`beginner`,`advanced`].map(n=>(0,z.jsx)(`button`,{type:`button`,className:t===n?`active`:``,"data-guide-audience":n,"aria-pressed":t===n,onClick:()=>r(n),children:e(n===`beginner`?`guide.mode.beginner`:`guide.mode.advanced`)},n))})]}),(0,z.jsxs)(`div`,{className:`guide-content`,children:[(0,z.jsxs)(`section`,{className:`guide-block`,"aria-labelledby":`guide-quick-start-title`,children:[(0,z.jsxs)(`div`,{className:`guide-block-head`,children:[(0,z.jsx)(`h3`,{id:`guide-quick-start-title`,children:e(`guide.quickStart.title`)}),(0,z.jsx)(`p`,{children:e(t===`beginner`?`guide.quickStart.subtitle.beginner`:`guide.quickStart.subtitle.advanced`)})]}),(0,z.jsx)(`ol`,{className:`guide-quick-start`,children:ig.map(n=>(0,z.jsxs)(`li`,{children:[(0,z.jsx)(`h4`,{children:e(`guide.quickStart.${n}.title`)}),(0,z.jsx)(`p`,{children:e(`guide.quickStart.${n}.${t}`)})]},n))})]}),(0,z.jsxs)(`section`,{className:`guide-flow`,"aria-labelledby":`guide-flow-title`,children:[(0,z.jsx)(`div`,{className:`guide-block-head`,children:(0,z.jsx)(`h3`,{id:`guide-flow-title`,children:e(`guide.flow.title`)})}),(0,z.jsxs)(`div`,{className:`guide-flow-row`,"aria-label":e(`guide.flow.aria`),children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(H,{"aria-hidden":!0}),(0,z.jsx)(`strong`,{children:e(`guide.flow.providers`)})]}),(0,z.jsx)(`span`,{className:`guide-flow-line`,"aria-hidden":!0}),(0,z.jsxs)(`div`,{className:`guide-flow-center`,children:[(0,z.jsx)(V,{"aria-hidden":!0}),(0,z.jsx)(`strong`,{children:e(`guide.flow.openCodex`)})]}),(0,z.jsx)(`span`,{className:`guide-flow-line`,"aria-hidden":!0}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(xe,{"aria-hidden":!0}),(0,z.jsx)(`strong`,{children:e(`guide.flow.clients`)})]})]}),(0,z.jsx)(`p`,{children:e(t===`beginner`?`guide.flow.note.beginner`:`guide.flow.note.advanced`)})]}),(0,z.jsxs)(`section`,{className:`guide-block`,"aria-labelledby":`guide-sections-title`,children:[(0,z.jsxs)(`div`,{className:`guide-block-head`,children:[(0,z.jsx)(`h3`,{id:`guide-sections-title`,children:e(`guide.sections.title`)}),(0,z.jsx)(`p`,{children:e(t===`beginner`?`guide.sections.subtitle.beginner`:`guide.sections.subtitle.advanced`)})]}),(0,z.jsx)(`div`,{className:`guide-section-grid`,children:rg.map(n=>{let r=e(n.labelKey),i=n.Icon;return(0,z.jsxs)(`article`,{className:`guide-section-card`,children:[(0,z.jsxs)(`div`,{className:`guide-section-card-head`,children:[(0,z.jsx)(`span`,{className:`guide-section-icon`,children:(0,z.jsx)(i,{"aria-hidden":!0})}),(0,z.jsx)(`h4`,{children:r})]}),(0,z.jsx)(`p`,{children:e(t===`beginner`?n.beginnerKey:n.advancedKey)}),(0,z.jsxs)(`dl`,{children:[(0,z.jsx)(`dt`,{children:e(`guide.section.includes`)}),(0,z.jsx)(`dd`,{children:e(n.includesKey)})]}),n.target&&(0,z.jsx)(`a`,{href:`#${n.target}`,onClick:e=>{e.preventDefault(),Ue(n.target)},children:e(`guide.section.open`,{section:r})})]},n.id)})})]})]})]})}function og(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.supported==`boolean`&&typeof t.installed==`boolean`&&typeof t.running==`boolean`&&typeof t.stale==`boolean`&&typeof t.summary==`string`}var sg={native:`startup.status.native`,protected:`startup.status.protected`,"at-risk":`startup.status.atRisk`},cg={native:`startup.summary.native`,protected:`startup.summary.protected`,"at-risk":`startup.summary.atRisk`},lg={service:`startup.protection.service`,shim:`startup.protection.shim`,none:`startup.protection.none`};function ug({ok:e,yes:t,no:n}){return(0,z.jsx)(`span`,{className:`badge ${e?`badge-green`:`badge-amber`}`,children:e?t:n})}function dg({failed:e,data:t}){let{t:n}=Z(),r=e?`startup-hero--risk`:t.status===`protected`?`startup-hero--safe`:t.status===`at-risk`?`startup-hero--risk`:`startup-hero--native`,i=e||t.status===`at-risk`?oe:J,a=t.routingKind===`opencodex-local`?`startup.routing.proxy`:t.routingKind===`custom-local`?`startup.routing.customLocal`:t.routingKind===`custom-remote`?`startup.routing.customRemote`:t.routingKind===`unknown`?`startup.routing.unknown`:`startup.routing.native`;return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`section`,{className:`panel startup-hero ${r}`,"aria-live":`polite`,children:[(0,z.jsx)(`div`,{className:`startup-hero-icon`,children:(0,z.jsx)(i,{})}),(0,z.jsxs)(`div`,{className:`startup-hero-copy`,children:[(0,z.jsx)(`span`,{className:`badge ${e||t.status===`at-risk`?`badge-amber`:`badge-green`}`,children:n(e?`startup.status.atRisk`:sg[t.status])}),(0,z.jsx)(`h3`,{children:n(e?`startup.error`:cg[t.status])}),(0,z.jsx)(`p`,{children:e?n(`startup.staleData`):t.status===`at-risk`?n(On(t)):n(`startup.safeDetail`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-state-grid`,children:[(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.routing`)}),(0,z.jsx)(`div`,{className:`value`,children:n(a)})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.restartProtection`)}),(0,z.jsx)(`div`,{className:`value`,children:n(lg[t.protection])})]}),(0,z.jsxs)(`section`,{className:`stat`,children:[(0,z.jsx)(`div`,{className:`label`,children:n(`startup.preference`)}),(0,z.jsx)(`div`,{className:`value`,children:n(t.autostartEnabled?`startup.enabled`:`startup.disabled`)})]})]})]})}function fg({data:e,failed:t,loading:n=!1,installBusy:r,installResult:i,onInstall:a}){let{t:o}=Z(),s=e.serviceSupported&&e.serviceInstalled&&e.serviceStale&&!e.serviceConflict,c=e.shimInstalled&&!e.shimHealthy,l=r!==null||t||n;return(0,z.jsxs)(`section`,{className:`panel startup-details`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:o(`startup.details`)}),(0,z.jsx)(`span`,{className:`muted mono`,children:e.platform})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.service`)}),(0,z.jsx)(`span`,{children:o(`startup.serviceHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(ug,{ok:e.serviceViable,yes:o(`startup.viable`),no:o(e.serviceConflict?`startup.conflict`:e.serviceStale?`startup.stale`:e.serviceInstalled?`startup.unhealthy`:e.serviceSupported?`startup.notInstalled`:`startup.unsupported`)}),e.serviceSupported&&!e.serviceInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-service`),children:o(r===`install-service`?`startup.installing`:`startup.install`)}),s&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.service`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-service`,{repair:!0}),children:o(r===`install-service`?`startup.repairing`:`startup.repair`)})]})]}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:o(`startup.shim`)}),(0,z.jsx)(`span`,{children:o(`startup.shimHint`)})]}),(0,z.jsxs)(`div`,{className:`startup-detail-actions`,children:[(0,z.jsx)(ug,{ok:e.shimHealthy&&e.autostartEnabled,yes:o(e.shimCoverage===`cli-only`?`startup.cliOnly`:`startup.healthy`),no:o(e.shimInstalled?e.shimHealthy&&!e.autostartEnabled?`startup.installedDisabled`:`startup.stale`:`startup.notInstalled`)}),!e.shimInstalled&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.install`)}`,disabled:l,onClick:()=>a(`install-shim`),children:o(r===`install-shim`?`startup.installing`:`startup.install`)}),c&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":`${o(`startup.shim`)} - ${o(`startup.repair`)}`,disabled:l,onClick:()=>a(`install-shim`,{repair:!0}),children:o(r===`install-shim`?`startup.repairing`:`startup.repair`)})]})]}),i&&(0,z.jsx)(`div`,{className:`notice ${i.kind===`success`?`notice-ok`:`notice-warn`} startup-action-notice`,role:`status`,"aria-live":`polite`,children:i.kind===`success`?i.action===`install-service`?o(i.repair?`startup.serviceRepaired`:`startup.serviceInstalled`):o(i.repair?`startup.shimRepaired`:`startup.shimInstalled`):`${o(`startup.installFailed`)} ${i.detail??``}`})]})}function pg({tray:e,trayLoading:t,trayError:n,trayBusy:r,onTrayAction:i}){let{t:a}=Z();return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:a(`startup.tray.title`)}),(0,z.jsx)(pe,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:a(`startup.tray.hint`)}),(0,z.jsxs)(`div`,{className:`startup-detail-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:a(`startup.tray.login`)}),(0,z.jsx)(`span`,{children:a(`startup.tray.notProtection`)})]}),t||n||!e?(0,z.jsx)(`span`,{className:`badge badge-amber`,children:a(t?`startup.tray.loading`:`startup.tray.unavailable`)}):(0,z.jsx)(ug,{ok:e.running&&!e.stale,yes:a(`startup.tray.running`),no:a(e.stale?`startup.tray.stale`:e.installed?`startup.tray.stopped`:`startup.tray.notInstalled`)})]}),(0,z.jsxs)(`div`,{className:`startup-tray-buttons`,children:[!t&&!n&&e&&!e.installed&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`install`),children:a(`startup.tray.install`)}),!t&&!n&&e?.installed&&!e.stale&&!e.running&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:r,onClick:()=>i(`start`),children:a(`startup.tray.start`)}),!t&&!n&&e?.running&&!e.stale&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:r,onClick:()=>i(`stop`),children:a(`startup.tray.stop`)}),!t&&!n&&e&&(e.installed||e.stale)&&(0,z.jsx)(`button`,{type:`button`,className:`btn btn-danger`,disabled:r,onClick:()=>{window.confirm(a(`startup.tray.uninstall`))&&i(`uninstall`)},children:a(`startup.tray.uninstall`)})]}),(n||e?.stale)&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-tray-error`,role:`alert`,children:a(`startup.tray.error`)})]})}function mg({data:e,copied:t,onCopy:n}){let{t:r}=Z(),i=jm(e.serviceInstalled&&!e.serviceConflict?e.commands.repairService:e.commands.installService),a=jm(e.commands.installShim),o=jm(e.commands.restoreNative),s=jm(e.recommendedCommand??e.commands.installService);return(0,z.jsxs)(`section`,{className:`panel startup-actions`,children:[(0,z.jsxs)(`div`,{className:`panel-head`,children:[(0,z.jsx)(`h3`,{className:`panel-title`,children:r(`startup.recovery`)}),(0,z.jsx)(te,{})]}),(0,z.jsx)(`p`,{className:`muted`,children:r(`startup.recoveryHint`)}),(0,z.jsxs)(`div`,{className:`startup-command-list`,children:[e.serviceSupported&&(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.service`)}),(0,z.jsx)(`code`,{children:i})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(i),children:r(t===i?`startup.copied`:`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.shim`)}),(0,z.jsx)(`code`,{children:a})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(a),children:r(t===a?`startup.copied`:`startup.copy`)})]}),(0,z.jsxs)(`div`,{className:`startup-command-row`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`strong`,{children:r(`startup.command.native`)}),(0,z.jsx)(`code`,{children:o})]}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n(o),children:r(t===o?`startup.copied`:`startup.copy`)})]})]}),e.status===`at-risk`&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-action-notice`,role:`alert`,children:[(0,z.jsx)(pe,{}),` `,r(`startup.recommended`,{cmd:s})]})]})}var hg=`ocx.startup.page.v1:`;function gg(e,t){let n=t===`win32`?`; `:` && `;return e.join(n)}function _g(e,t,n){if(!e)return{warning:null,fix:null};let r=!!e.catalogClamp?.active,i=!!e.newerAvailable,a=(r?e.catalogClamp?.runtimeVersion:e.version)??e.version??`unknown`,o=(e.catalogClamp?.removedEfforts??[]).join(`, `),s=gg([`rmx doctor --fix-codex-runtime`,`rmx sync`],n);return r?{warning:o?t(`startup.codexRuntime.clampHiddenWithEfforts`,{version:a,efforts:o}):t(`startup.codexRuntime.clampHidden`,{version:a}),fix:i?s:`rmx sync`}:i?{warning:t(`startup.codexRuntime.olderBinary`,{version:a}),fix:s}:{warning:null,fix:null}}function vg({apiBase:e}){let{t}=Z(),n=`${hg}${e}`,r=(0,_.useMemo)(()=>En(n),[n]),i=`startup-page:${e}`,[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(()=>r?.tray??null),[l,u]=(0,_.useState)(()=>!r?.data),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(()=>r?.warning??null),[S,C]=(0,_.useState)(()=>r?.fix??null),[w,T]=(0,_.useState)(()=>!r?.data),E=(0,_.useRef)(!!r?.data),D=(0,_.useCallback)(async r=>{let i=E.current;i||(u(!0),T(!0));try{let i=fetch(`${e}/api/settings`,{signal:r}).then(async e=>e.ok?await e.json():null).catch(()=>null),a=await fetch(`${e}/api/startup-health`,{signal:r});if(!a.ok)throw Error(`fetch failed`);let o=await a.json();y(e=>e?.kind===`error`&&(o.status===`native`&&e.forLocalRouting===!0||(e.action===`install-service`?o.serviceViable:o.shimInstalled&&o.shimHealthy))?null:e),E.current=!0;let s=En(n);Dn(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:s?.tray??null});let l=o.platform===`win32`?fetch(`${e}/api/windows-tray`,{signal:r}).then(async e=>{if(!e.ok)throw Error(`tray status failed`);let t=await e.json();if(!og(t))throw Error(`invalid tray status`);return{tray:t,error:!1}}).catch(()=>({tray:null,error:!0})):Promise.resolve({tray:null,error:!1});return Promise.all([i,l]).then(([e,i])=>{if(r.aborted)return;let a=o.platform===`win32`?i.tray:null;if(o.platform===`win32`?(c(a),m(i.error)):(c(null),m(!1)),u(!1),T(!1),e){let r=_g(e.codexRuntime,t,o.platform);x(r.warning),C(r.fix),Dn(n,{data:o,warning:r.warning,fix:r.fix,tray:a});return}let s=En(n);Dn(n,{data:o,warning:s?.warning??null,fix:s?.fix??null,tray:a})}),o}catch(e){throw r.aborted?e:(i||(c(null),m(!0),x(null),C(null)),T(!1),u(!1),e)}},[e,n,t]),O=bs(i,[e],D,{isEmpty:()=>!1,initialData:r?.data??void 0}),k=O.state,A=O.refresh,j=k.data??r?.data??null,M=k.refreshing,N=!!j?.diagnosticStale||k.showError;(0,_.useEffect)(()=>{if(!j?.diagnosticStale)return;let e=window.setTimeout(A,2e3);return()=>window.clearTimeout(e)},[j,A]);let P=async e=>{try{await navigator.clipboard.writeText(e),o(e),window.setTimeout(()=>o(t=>t===e?null:t),1600)}catch{o(null)}},F=async t=>{f(!0),m(!1);try{let n=await fetch(`${e}/api/windows-tray`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t})});if(!n.ok)throw Error(`tray action failed`);let r=await n.json();if(!og(r.status))throw Error(`invalid tray action status`);c(r.status),m(!1)}catch{c(null),m(!0)}finally{f(!1)}},I=async(t,n)=>{g(t),y(null);try{let r=await fetch(`${e}/api/startup-action`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:t,repair:n?.repair===!0})});if(!r.ok){let e=await r.json().catch(()=>null);throw Error(typeof e?.error==`string`?e.error:`installation failed`)}y({kind:`success`,action:t,repair:n?.repair===!0}),A()}catch(e){y({kind:`error`,action:t,repair:n?.repair===!0,detail:e instanceof Error?e.message:String(e),forLocalRouting:j?.localRoutingDependency===!0})}finally{g(null)}};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`page-head`,children:[(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h2`,{children:t(`startup.title`)}),(0,z.jsx)(`p`,{className:`page-sub startup-page-sub`,children:t(`startup.subtitle`)})]}),(0,z.jsxs)(`div`,{className:`startup-page-head-actions`,children:[(0,z.jsx)(`a`,{className:`btn btn-ghost btn-sm`,href:`#dashboard`,children:t(`startup.backToDashboard`)}),(0,z.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),disabled:M,children:[(0,z.jsx)(X,{}),` `,t(`startup.refresh`)]})]})]}),k.showSkeleton&&!j?(0,z.jsx)(Ss,{label:t(`startup.loading`),rows:5}):k.kind===`failed-cold`?(0,z.jsxs)(`div`,{className:`startup-page-notice`,children:[(0,z.jsx)($,{tone:`err`,children:k.error instanceof Error?k.error.message:t(`startup.error`)}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>A(),children:t(`common.retry`)})]}):j?(0,z.jsxs)(z.Fragment,{children:[k.showError&&(0,z.jsx)($,{tone:`err`,children:t(`startup.error`)}),N&&(0,z.jsx)(`div`,{className:`notice notice-warn startup-page-notice`,role:`alert`,children:t(`startup.staleData`)}),(w||b)&&(0,z.jsx)(`div`,{className:`startup-runtime-notice-slot${w&&!b?` startup-runtime-notice-slot--pending`:``}`,"aria-hidden":w&&!b?!0:void 0,children:b&&(0,z.jsxs)(`div`,{className:`notice notice-warn startup-page-notice startup-runtime-notice`,role:`status`,children:[(0,z.jsx)(`p`,{className:`startup-runtime-notice__text`,children:b}),S&&(0,z.jsxs)(`div`,{className:`startup-runtime-notice__fix`,children:[(0,z.jsx)(`code`,{children:S}),(0,z.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>void P(S),children:t(a===S?`startup.copied`:`startup.copy`)})]})]})}),(0,z.jsx)(dg,{failed:N,data:j}),(0,z.jsx)(fg,{data:j,failed:N,loading:M,installBusy:h,installResult:v,onInstall:(e,t)=>{I(e,t)}}),j.platform===`win32`&&(0,z.jsx)(pg,{tray:s,trayLoading:l,trayError:p,trayBusy:d,onTrayAction:e=>{F(e)}}),(0,z.jsx)(mg,{data:j,copied:a,onCopy:e=>{P(e)}})]}):null]})}function yg({onOpenUpdate:e}){let t=Q();return(0,z.jsxs)(`button`,{type:`button`,className:`sidebar-link sidebar-update-action`,onClick:e,"aria-label":t(`sidebar.checkUpdate`),title:t(`sidebar.checkUpdate`),children:[(0,z.jsx)(de,{"aria-hidden":`true`}),(0,z.jsx)(`span`,{children:t(`sidebar.checkUpdate`)})]})}var bg=`opencodex-admin-token-dialog`,xg=`Remodex`;function Sg(e,t=Fe()){let n=Ae[t],r=n[`auth.adminTokenTitle`];return new Promise(t=>{let i=document.activeElement instanceof HTMLElement?document.activeElement:null,a=!1,o=document.createElement(`dialog`);o.id=bg,o.className=`modal-overlay`,o.setAttribute(`aria-labelledby`,`${bg}-title`);let s=document.createElement(`form`);s.className=`modal-card`,s.method=`post`,s.action=window.location.href,s.autocomplete=`on`;let c=document.createElement(`div`);c.className=`modal-head`;let l=document.createElement(`h3`);l.id=`${bg}-title`,l.textContent=r,c.append(l);let u=document.createElement(`div`),d=document.createElement(`label`);d.className=`field-label`,d.htmlFor=`${bg}-username`,d.textContent=n[`auth.adminAccountLabel`];let f=document.createElement(`input`);f.id=d.htmlFor,f.className=`input`,f.type=`text`,f.name=`username`,f.autocomplete=`username`,f.value=xg,f.readOnly=!0,u.append(d,f);let p=document.createElement(`div`);p.style.marginTop=`var(--space-4)`;let m=document.createElement(`label`);m.className=`field-label`,m.htmlFor=`${bg}-password`,m.textContent=n[`auth.adminTokenFieldLabel`];let h=document.createElement(`input`);h.id=m.htmlFor,h.className=`input`,h.type=`password`,h.name=`password`,h.autocomplete=`current-password`,h.required=!0,h.spellcheck=!1,h.autocapitalize=`none`,p.append(m,h);let g=document.createElement(`div`);g.className=`notice notice-err`,g.setAttribute(`role`,`alert`),g.hidden=!0;let _=document.createElement(`div`);_.className=`modal-actions`;let v=document.createElement(`button`);v.type=`button`,v.className=`btn btn-ghost`,v.textContent=n[`common.cancel`];let y=document.createElement(`button`);y.type=`submit`,y.className=`btn btn-primary`,y.textContent=n[`common.ok`],_.append(v,y),s.append(c,u,p,g,_),o.append(s);let b=e=>{a||(a=!0,o.open&&o.close(),o.remove(),i?.focus(),t(e))};s.addEventListener(`submit`,t=>{t.preventDefault();let r=h.value.trim();if(!r){h.value=``,h.reportValidity();return}h.disabled=!0,y.disabled=!0,g.hidden=!0,e(r).then(e=>{if(!a){if(e===`accepted`){b(r);return}h.value=``,h.disabled=!1,y.disabled=!1,g.textContent=e===`rejected`?n[`auth.adminTokenRejected`]:n[`auth.adminTokenUnavailable`],g.hidden=!1,h.focus()}}).catch(()=>{a||(h.value=``,h.disabled=!1,y.disabled=!1,g.textContent=n[`auth.adminTokenUnavailable`],g.hidden=!1,h.focus())})}),v.addEventListener(`click`,()=>b(null)),o.addEventListener(`cancel`,e=>{e.preventDefault(),b(null)}),document.body.append(o),typeof o.showModal==`function`?o.showModal():o.setAttribute(`open`,``),queueMicrotask(()=>h.focus())})}var Cg=!1,wg=null,Tg=null,Eg=!1,Dg=Sg,Og=`/opencodex-session`,kg=`/api/settings`;function Ag(e){try{let t=e instanceof Request?e.url:String(e),n=new URL(t,window.location.href);return n.origin===window.location.origin&&n.pathname.startsWith(`/api/`)}catch{return!1}}var jg=`opencodex-api-token`,Mg=null,Ng=null,Pg=null;function Fg(){return Mg}function Ig(e){Mg=e}function Lg(){Mg=null,Ng=null,Pg=null}function Rg(e){let t=document.querySelector(`meta[name="${e}"]`),n=t?.content.trim()||null;return t?.remove(),n}function zg(){Vg(Rg(`opencodex-session-token`),Rg(`opencodex-session-csrf`),Rg(`opencodex-session-origin`))}function Bg(e){e!=null&&Fg()===e&&Lg()}function Vg(e,t,n){return!e?.startsWith(`ocx_session_`)||!t||n!==window.location.origin?!1:(Mg=e,Ng=t,Pg=n,!0)}function Hg(e,t){for(let n of e.match(/<meta\b[^>]*>/gi)??[])if(n.match(/\bname="([^"]+)"/i)?.[1]===t)return n.match(/\bcontent="([^"]*)"/i)?.[1]?.trim()||null;return null}async function Ug(){if(!Tg)return null;try{let e=await Tg(Og,{cache:`no-store`});if(!e.ok)return null;let t=await e.text();return Vg(Hg(t,`opencodex-session-token`),Hg(t,`opencodex-session-csrf`),Hg(t,`opencodex-session-origin`))?Fg():null}catch{return null}}async function Wg(e){if(!Tg)return`unavailable`;try{let[t,n]=Kg(kg,{cache:`no-store`},e),r=await Tg(t,n);return r.status===401?`rejected`:r.ok?`accepted`:`unavailable`}catch{return`unavailable`}}function Gg(){try{sessionStorage.removeItem(jg)}catch{}}function Kg(e,t,n){let r=new Headers(t?.headers??(e instanceof Request?e.headers:void 0));if(r.set(`X-OpenCodex-API-Key`,n),Pg&&Ng&&n.startsWith(`ocx_session_`)){r.set(`X-OpenCodex-GUI-Origin`,Pg);let n=(t?.method??(e instanceof Request?e.method:`GET`)).toUpperCase();n!==`GET`&&n!==`HEAD`&&r.set(`X-OpenCodex-CSRF-Token`,Ng)}return e instanceof Request?[new Request(e,{headers:r}),t?{...t,headers:r}:void 0]:[e,{...t,headers:r}]}async function qg(e){return Eg?null:wg||(wg=(async()=>{if(Eg)return null;let t=Fg();if(t&&t!==e)return t;let n=await Ug();if(n)return n;let r=await Dg(Wg);return r?(Ig(r),r):(Eg=!0,null)})().finally(()=>{wg=null}),wg)}function Jg(){if(Cg)return;Cg=!0,Gg(),zg();let e=window.fetch.bind(window);Tg=e,window.fetch=async(t,n)=>{if(!Ag(t))return e(t,n);let r=Fg(),[i,a]=r?Kg(t,n,r):[t,n],o=await e(i,a);if(o.status!==401)return o;let s=Fg();if(s&&s!==r){let[r,i]=Kg(t,n,s),a=await e(r,i);if(a.status!==401)return a;Bg(s)}else Bg(r);let c=await qg(r);if(!c)return o;let[l,u]=Kg(t,n,c),d=await e(l,u);return d.status===401&&Bg(c),d}}var Yg=[`ocx-global-view`,`ocx-view`,`ocx-providers-view`,`ocx-subagents-view`,`ocx-storage-view`,`ocx-codexauth-view`,`ocx-apikeys-view`,`ocx-claudecode-view`,`ocx-usage-view`,`ocx-logs-view`,`ocx-models-view`,`ocx-dashboard-view`];function Xg(){try{for(let e of Yg)localStorage.removeItem(e)}catch{}}function Zg(){let[e,t]=(0,_.useState)(vh);(0,_.useEffect)(()=>{Xg()},[]);let n=(0,_.useCallback)(e=>{let n=Ch(e);n.replaceTo&&He(n.replaceTo),t(n.page)},[]);return(0,_.useEffect)(()=>{let e=()=>{n(Ve(window.location.hash))};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[n]),(0,_.useEffect)(()=>{let n=Ch(Ve(window.location.hash));n.replaceTo&&He(n.replaceTo),n.page!==e&&t(n.page)},[e]),{page:e,setPageState:t,navigateToPage:(e,n)=>{Ue(n?`${e}/${n}`:e),t(e)}}}var Qg=15e3;function $g(e,t,n){return typeof e?.message==`string`&&e.message.trim()?e.message:typeof e?.error==`string`&&e.error.trim()?e.error:n(t)}function e_(e){return(e instanceof DOMException||e instanceof Error)&&e.name===`AbortError`}async function t_(e,t={}){let{fetchFn:n=fetch,timeoutMs:r=Qg,formatFailure:i=e=>`Failed to stop proxy (HTTP ${e}).`}=t,a;try{a=await n(`${e}/api/stop`,{method:`POST`,signal:AbortSignal.timeout(r)})}catch(e){return e_(e),{accepted:!0}}let o=await a.json().catch(()=>null);return!a.ok||o?.success===!1?{accepted:!1,message:$g(o,a.status,i)}:{accepted:!0}}Jg();var n_={dashboard:`nav.dashboard`,startup:`nav.startup`,providers:`nav.providers`,models:`nav.models`,subagents:`nav.subagents`,logs:`nav.logs`,"desktop-logs":`nav.desktopLogs`,usage:`nav.usage`,storage:`nav.storage`,"codex-auth":`nav.codexAuth`,integrations:`nav.integrations`,"android-remote":`nav.androidRemote`,guide:`nav.guide`},r_=``,i_=`ocx-theme`,a_=[{id:`dashboard`,tkey:`nav.dashboard`,Icon:V},{id:`codex-auth`,tkey:`nav.codexAuth`,Icon:he},{id:`providers`,tkey:`nav.providers`,Icon:H},{id:`models`,tkey:`nav.models`,Icon:U},{id:`subagents`,tkey:`nav.subagents`,Icon:W},{id:`logs`,tkey:`nav.logs`,Icon:G},{id:`desktop-logs`,tkey:`nav.desktopLogs`,Icon:te},{id:`usage`,tkey:`nav.usage`,Icon:K},{id:`storage`,tkey:`nav.storage`,Icon:q},{id:`integrations`,tkey:`nav.integrations`,Icon:Se},{id:`android-remote`,tkey:`nav.androidRemote`,Icon:Ce},{id:`guide`,tkey:`nav.guide`,Icon:we}],o_={light:ye,dark:be,system:xe},s_={light:`theme.light`,dark:`theme.dark`,system:`theme.system`};function c_(e){if(!e||typeof e!=`object`||!(`version`in e))return null;let t=e.version;return typeof t==`string`&&t.length>0?t:null}function l_(){let e=localStorage.getItem(i_);return e===`light`||e===`dark`?e:`system`}function u_(){let{page:e,navigateToPage:t}=Zg(),[n,r]=(0,_.useState)(il);(0,_.useEffect)(()=>{let e=()=>r(il());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let[i,a]=(0,_.useState)(l_),{locale:o,setLocale:s}=Z(),c=Q(),[l,u]=(0,_.useState)(!1),d=(0,_.useRef)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=()=>u(!1);return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]),(0,_.useEffect)(()=>{let e=document.documentElement;i===`system`?(e.removeAttribute(`data-theme`),localStorage.removeItem(i_)):(e.setAttribute(`data-theme`,i),localStorage.setItem(i_,i))},[i]);let m=I(`app-healthz:${r_}`,[],async e=>{let t=await fetch(`${r_}/healthz`,{signal:e});return t.ok?c_(await t.json()):null},{pollMs:3e4}),h=()=>a(e=>e===`light`?`dark`:e===`dark`?`system`:`light`),g=o_[i],v=m.data??`1.0.5`,[y,b]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),C=(0,_.useRef)(!1);(0,_.useEffect)(()=>{let e=!1,t,n=async()=>{let r=await Os();!e&&r&&S(r),e||(t=setTimeout(n,1e3))};return n(),()=>{e=!0,t&&clearTimeout(t)}},[]),(0,_.useEffect)(()=>{if(x){if(x.state===`offline`){C.current=!0;return}C.current&&(x.state===`ready`||x.state===`degraded`)&&window.location.reload()}},[x]),(0,_.useEffect)(()=>{if(!l)return;let e=e=>{e.key===`Escape`&&u(!1)};window.addEventListener(`keydown`,e);let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{window.removeEventListener(`keydown`,e),document.body.style.overflow=t}},[l]),(0,_.useEffect)(()=>{if(l){p.current=!0;let e=setTimeout(()=>f.current?.focus(),200);return()=>clearTimeout(e)}p.current&&(p.current=!1,d.current?.focus())},[l]),(0,_.useEffect)(()=>{let e=window.matchMedia(`(min-width: 761px)`),t=()=>{e.matches&&u(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let w=async()=>{let e=x?.state===`offline`;if(!e&&!confirm(c(`dash.stopConfirm`)))return;if(b(!0),x){try{S(await ks(e))}catch(t){let n=t instanceof Error?t.message:String(t);alert(c(e?`dash.startFailed`:`dash.lifecycleFailed`,{message:n}))}finally{b(!1)}return}let t=await t_(r_,{formatFailure:e=>c(`dash.stopFailed`,{status:String(e)})});t.accepted||(b(!1),alert(t.message))},T=x?.state===`offline`?`dash.start`:x?.state===`starting`?`dash.starting`:x?.state===`stopping`||y?`dash.stopping`:`dash.stop`,E=y||x?.state===`starting`||x?.state===`stopping`,D=(0,z.jsxs)(`div`,{className:`brand`,children:[(0,z.jsx)(`span`,{className:`brand-logo`,role:`img`,"aria-label":c(`app.logoAria`)}),(0,z.jsx)(`span`,{className:`name`,children:`Remodex`}),(0,z.jsxs)(`span`,{className:`ver`,children:[`v`,v]})]});return(0,z.jsxs)(`div`,{className:`app`,children:[(0,z.jsxs)(`header`,{className:`mobile-topbar`,inert:l,children:[(0,z.jsx)(`button`,{ref:d,type:`button`,className:`menu-toggle`,onClick:()=>u(e=>!e),"aria-expanded":l,"aria-controls":`app-sidebar`,"aria-label":c(l?`nav.closeMenu`:`nav.openMenu`),title:c(l?`nav.closeMenu`:`nav.openMenu`),children:(0,z.jsx)(ee,{})}),D,(0,z.jsx)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:w,disabled:E,"aria-label":c(T),title:c(T),children:(0,z.jsx)(pe,{})})]}),l&&(0,z.jsx)(`div`,{className:`drawer-scrim`,onClick:()=>u(!1),"aria-hidden":`true`}),(0,z.jsxs)(`aside`,{id:`app-sidebar`,className:`sidebar${l?` open`:``}`,ref:f,tabIndex:-1,children:[(0,z.jsxs)(`div`,{className:`drawer-head`,children:[D,(0,z.jsx)(`button`,{type:`button`,className:`menu-toggle drawer-close`,onClick:()=>u(!1),"aria-label":c(`nav.closeMenu`),title:c(`nav.closeMenu`),children:(0,z.jsx)(Y,{})})]}),(0,z.jsx)(`nav`,{children:a_.map(n=>{let{id:r,tkey:i,Icon:a}=n,o=r===e;return(0,z.jsx)(`div`,{className:`nav-entry`,children:(0,z.jsxs)(`button`,{type:`button`,className:`nav-item${o?` active`:``}`,"data-page":r,onClick:()=>{t(r),u(!1)},"aria-current":o?`page`:void 0,children:[(0,z.jsx)(a,{}),` `,c(i)]})},r)})}),(0,z.jsxs)(`div`,{className:`sidebar-foot`,children:[(0,z.jsxs)(`div`,{className:`lang-toggle`,children:[(0,z.jsx)(Se,{"aria-hidden":!0}),(0,z.jsx)(rt,{value:o,options:je.map(e=>({value:e.code,label:e.name})),onChange:e=>s(e),label:c(`lang.label`),placement:`right`,portal:!1,style:{flex:1,minWidth:0,width:`100%`}})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle`,onClick:h,"aria-label":`${c(`theme.label`)}: ${c(s_[i])}`,title:`${c(`theme.label`)}: ${c(s_[i])}`,children:[(0,z.jsx)(g,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:c(s_[i])})]}),(0,z.jsxs)(`button`,{type:`button`,className:`theme-toggle stop-toggle`,onClick:w,disabled:E,"aria-label":c(T),title:c(T),children:[(0,z.jsx)(pe,{}),` `,(0,z.jsx)(`span`,{className:`mode`,children:c(T)})]}),(0,z.jsx)(yg,{onOpenUpdate:()=>{u(!1),t(`dashboard`,`update`)}})]})]}),(0,z.jsx)(`main`,{className:`main`,inert:l,children:(0,z.jsx)(`div`,{className:`main-inner${e===`models`&&n===`combos`?` main-inner--combos`:``}`,children:(0,z.jsxs)(Ns,{pageName:c(n_[e]),title:c(`errorBoundary.title`),message:c(`errorBoundary.message`),detailsLabel:c(`errorBoundary.details`),reloadLabel:c(`errorBoundary.reload`),children:[e===`dashboard`&&(0,z.jsx)(tr,{apiBase:r_}),e===`startup`&&(0,z.jsx)(vg,{apiBase:r_}),e===`providers`&&(0,z.jsx)(ps,{apiBase:r_}),e===`models`&&(0,z.jsx)(Pl,{apiBase:r_},r_),e===`subagents`&&(0,z.jsx)(Wl,{apiBase:r_},r_),e===`logs`&&(0,z.jsx)(md,{apiBase:r_}),e===`desktop-logs`&&(0,z.jsx)(xd,{}),e===`usage`&&(0,z.jsx)(Vd,{apiBase:r_}),e===`storage`&&(0,z.jsx)(af,{apiBase:r_}),e===`codex-auth`&&(0,z.jsx)(ff,{apiBase:r_}),e===`integrations`&&(0,z.jsx)(oh,{apiBase:r_}),e===`android-remote`&&(0,z.jsx)(Qh,{apiBase:r_}),e===`guide`&&(0,z.jsx)(ag,{})]},e)})})]})}var d_=new WeakSet,f_=new Map,p_=5e3,m_=64,h_=8e3;function g_(e){if(e)return e.length<=h_?e:`${e.slice(0,7999)}…`}function __(e){return e instanceof Error?{message:g_(e.message)||e.name||`Unhandled error`,stack:g_(e.stack)}:typeof e==`string`?{message:g_(e)||`Unhandled rejection`}:e===null?{message:`Unhandled rejection: null`}:e===void 0?{message:`Unhandled rejection: undefined`}:{message:`Unhandled rejection: ${Object.prototype.toString.call(e)}`}}function v_(e){let t=Date.now(),n=`${e.kind}\u0000${e.message}\u0000${e.source??``}`,r=f_.get(n);if(r!==void 0&&t-r<p_)return!1;if(f_.set(n,t),f_.size>m_){let e=[...f_.entries()].sort((e,t)=>e[1]-t[1])[0];e&&f_.delete(e[0])}return!0}function y_(e){v_(e)&&Ms(e)}function b_(e=window){d_.has(e)||(d_.add(e),e.addEventListener(`error`,t=>{let n=__(t.error??t.message);y_({kind:`window-error`,message:n.message,stack:n.stack,source:g_([t.filename,t.lineno>0?String(t.lineno):``,t.colno>0?String(t.colno):``].filter(Boolean).join(`:`)),page:g_(e.location.hash||`#dashboard`)})}),e.addEventListener(`unhandledrejection`,t=>{let n=__(t.reason);y_({kind:`unhandled-rejection`,message:n.message,stack:n.stack,page:g_(e.location.hash||`#dashboard`)})}))}b_(),g.createRoot(document.getElementById(`root`)).render((0,z.jsx)(_.StrictMode,{children:(0,z.jsx)(ze,{children:(0,z.jsx)(u_,{})})}));
@@ -16,7 +16,7 @@
16
16
  } catch (e) {}
17
17
  })();
18
18
  </script>
19
- <script type="module" crossorigin src="/assets/index-D3MaPif3.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-B-jlbgno.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-1SDbgh2-.css">
21
21
  </head>
22
22
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remodex/rmx",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Remodex universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code",
5
5
  "displayName": "Remodex",
6
6
  "type": "module",
@@ -6,6 +6,8 @@ import { resolveCodexRuntime } from "../codex/runtime";
6
6
  const DEFAULT_CODEX_APP_SERVER_PORT = 10106;
7
7
  const START_TIMEOUT_MS = 12_000;
8
8
  const REQUEST_TIMEOUT_MS = 30_000;
9
+ const OWNED_PROCESS_TERM_GRACE_MS = 1_000;
10
+ const OWNED_PROCESS_KILL_GRACE_MS = 1_000;
9
11
 
10
12
  const APP_SERVER_PROFILE_KEYS = new Set([
11
13
  "model_provider",
@@ -353,6 +355,45 @@ async function waitUntilReady(port: number, child: Bun.Subprocess): Promise<void
353
355
  throw new Error("Codex task server did not become ready");
354
356
  }
355
357
 
358
+ type KillableSubprocess = Pick<Bun.Subprocess, "kill" | "exited">;
359
+
360
+ function waitForSubprocessExit(child: KillableSubprocess, timeoutMs: number): Promise<boolean> {
361
+ return new Promise(resolve => {
362
+ let settled = false;
363
+ let timer: ReturnType<typeof setTimeout> | undefined;
364
+ const finish = (exited: boolean): void => {
365
+ if (settled) return;
366
+ settled = true;
367
+ if (timer !== undefined) clearTimeout(timer);
368
+ resolve(exited);
369
+ };
370
+ timer = setTimeout(() => finish(false), Math.max(0, timeoutMs));
371
+ // A failed exit promise still means the child is no longer running. The
372
+ // rejection is consumed here so shutdown never creates an unhandled error.
373
+ void child.exited.then(() => finish(true), () => finish(true));
374
+ });
375
+ }
376
+
377
+ /**
378
+ * Stop a process that the current Remodex runtime explicitly spawned.
379
+ *
380
+ * Codex normally honors SIGTERM, but an app-server can be wedged while its
381
+ * listener is being torn down. Keep the wait bounded and escalate only for
382
+ * this caller-owned handle; callers must never pass a process they did not
383
+ * create and positively mark as owned.
384
+ */
385
+ export async function terminateOwnedCodexProcess(
386
+ child: KillableSubprocess,
387
+ termGraceMs = OWNED_PROCESS_TERM_GRACE_MS,
388
+ killGraceMs = OWNED_PROCESS_KILL_GRACE_MS,
389
+ ): Promise<void> {
390
+ try { child.kill("SIGTERM"); } catch { /* already exited */ }
391
+ if (await waitForSubprocessExit(child, termGraceMs)) return;
392
+
393
+ try { child.kill("SIGKILL"); } catch { /* already exited */ }
394
+ await waitForSubprocessExit(child, killGraceMs);
395
+ }
396
+
356
397
  export type AndroidCodexRuntimeStatus = {
357
398
  connected: boolean;
358
399
  port: number;
@@ -553,13 +594,8 @@ export class AndroidCodexRuntime {
553
594
  private async stopOwnedProcess(): Promise<void> {
554
595
  const child = this.child;
555
596
  this.child = null;
556
- if (child && this.ownedProcess) {
557
- try { child.kill(); } catch { /* already exited */ }
558
- await Promise.race([
559
- child.exited.catch(() => -1),
560
- new Promise(resolve => setTimeout(resolve, 1_000)),
561
- ]);
562
- }
597
+ const owned = child !== null && this.ownedProcess;
563
598
  this.ownedProcess = false;
599
+ if (owned) await terminateOwnedCodexProcess(child);
564
600
  }
565
601
  }
@@ -5,6 +5,7 @@ import { homedir, networkInterfaces, hostname as readHostname } from "node:os";
5
5
  import { basename, dirname, isAbsolute, join, parse, resolve } from "node:path";
6
6
  import type { Server, ServerWebSocket } from "bun";
7
7
  import { getConfigDir } from "../config";
8
+ import { redactSecretString } from "../lib/redact";
8
9
  import { commandInvocation } from "../lib/win-exec";
9
10
  import type { ManagementModelRow } from "../server/management/model-rows";
10
11
  import { modelSourceDisplayName } from "../model-sources";
@@ -351,6 +352,58 @@ function stringValue(value: unknown, maximum = 4096): string {
351
352
  return typeof value === "string" ? value.trim().slice(0, maximum) : "";
352
353
  }
353
354
 
355
+ /**
356
+ * Keep the lifecycle error actionable without echoing credentials or an
357
+ * unbounded exception string through the management API. Startup failures
358
+ * are otherwise indistinguishable from a transient tunnel failure, which
359
+ * makes `rmx onboard --verbose` misleading.
360
+ */
361
+ function startupErrorText(error: unknown): string {
362
+ const parts: string[] = [];
363
+ const seen = new Set<object>();
364
+ let current: unknown = error;
365
+ for (let depth = 0; depth < 4 && current !== undefined && current !== null; depth += 1) {
366
+ if ((typeof current === "object" || typeof current === "function") && current !== null) {
367
+ if (seen.has(current)) break;
368
+ seen.add(current);
369
+ }
370
+ if (current instanceof Error) {
371
+ if (current.message.trim()) parts.push(current.message.trim());
372
+ current = current.cause;
373
+ continue;
374
+ }
375
+ const object = record(current);
376
+ if (object) {
377
+ if (typeof object.message === "string" && object.message.trim()) {
378
+ parts.push(object.message.trim());
379
+ }
380
+ current = object.cause;
381
+ continue;
382
+ }
383
+ const text = String(current).trim();
384
+ if (text) parts.push(text);
385
+ break;
386
+ }
387
+ return parts.filter((part, index) => index === 0 || part !== parts[index - 1]).join(": ");
388
+ }
389
+
390
+ function gatewayStartupError(error: unknown): string {
391
+ const raw = startupErrorText(error);
392
+ const safe = redactSecretString(raw)
393
+ .replace(/[\u0000-\u001f\u007f]/gu, " ")
394
+ .replace(/\s+/gu, " ")
395
+ .trim()
396
+ .slice(0, 240);
397
+ const prefix = "Could not start the Android Remote gateway";
398
+ // Runtime adapters may already use the public prefix. Strip any repeated
399
+ // wrapper before adding one canonical, actionable message.
400
+ let detail = safe;
401
+ while (new RegExp(`^${prefix}(?::|\\s|$)`, "iu").test(detail)) {
402
+ detail = detail.slice(prefix.length).replace(/^:\s*/u, "").trim();
403
+ }
404
+ return detail ? `${prefix}: ${detail}` : prefix;
405
+ }
406
+
354
407
  function desktopConversationIsActive(value: unknown): boolean | null {
355
408
  const state = record(value);
356
409
  if (!state) return null;
@@ -1978,6 +2031,8 @@ export class AndroidRemoteGatewayController {
1978
2031
  private server: Server<GatewayWsData> | null = null;
1979
2032
  private codex: AndroidCodexClient | null = null;
1980
2033
  private unsubscribeCodex: (() => void) | null = null;
2034
+ /** All callers must await one physical gateway startup. */
2035
+ private startFlight: Promise<void> | null = null;
1981
2036
  private transition: Promise<void> = Promise.resolve();
1982
2037
  private readonly sockets = new Set<ServerWebSocket<GatewayWsData>>();
1983
2038
  private readonly socketsByClient = new Map<string, Set<ServerWebSocket<GatewayWsData>>>();
@@ -2371,7 +2426,19 @@ export class AndroidRemoteGatewayController {
2371
2426
  }
2372
2427
 
2373
2428
  async start(): Promise<void> {
2374
- if (this.gatewayStatus === "ready" || this.gatewayStatus === "starting") return;
2429
+ if (this.gatewayStatus === "ready") return;
2430
+ if (this.startFlight) return this.startFlight;
2431
+
2432
+ const flight = this.startInternal();
2433
+ this.startFlight = flight;
2434
+ try {
2435
+ await flight;
2436
+ } finally {
2437
+ if (this.startFlight === flight) this.startFlight = null;
2438
+ }
2439
+ }
2440
+
2441
+ private async startInternal(): Promise<void> {
2375
2442
  this.gatewayStatus = "starting";
2376
2443
  this.statusError = undefined;
2377
2444
  try {
@@ -2396,15 +2463,17 @@ export class AndroidRemoteGatewayController {
2396
2463
  for (const remoteThreadId of this.queuedTurns.keys()) {
2397
2464
  void this.startNextQueuedTurn(remoteThreadId).catch(() => undefined);
2398
2465
  }
2399
- } catch {
2466
+ } catch (error) {
2400
2467
  this.gatewayStatus = "error";
2401
- this.statusError = "Could not start the Android Remote gateway";
2468
+ this.statusError = gatewayStartupError(error);
2402
2469
  await this.stopResources();
2403
- throw new Error(this.statusError);
2470
+ throw new Error(this.statusError, { cause: error });
2404
2471
  }
2405
2472
  }
2406
2473
 
2407
2474
  async stop(): Promise<void> {
2475
+ const starting = this.startFlight;
2476
+ if (starting) await starting.catch(() => undefined);
2408
2477
  await this.stopResources();
2409
2478
  this.gatewayStatus = "stopped";
2410
2479
  this.statusError = undefined;
@@ -12,6 +12,7 @@ import {
12
12
  } from "../codex/desired-state";
13
13
  import { syncModelsToCodex, type CodexSyncResult } from "../codex/sync";
14
14
  import { openUrl } from "../lib/open-url";
15
+ import { redactSecretString } from "../lib/redact";
15
16
  import {
16
17
  assertServiceEnvironmentMatchesInstall,
17
18
  diagnoseService,
@@ -33,6 +34,8 @@ const ONBOARD_STEPS = 6;
33
34
  const DEFAULT_PROXY_WAIT_MS = 45_000;
34
35
  const DEFAULT_TUNNEL_WAIT_MS = 180_000;
35
36
  const CAPTURE_LIMIT = 96 * 1024;
37
+ const GATEWAY_RETRY_LIMIT = 2;
38
+ const GATEWAY_RETRY_DELAY_MS = 750;
36
39
 
37
40
  export type OnboardOptions = {
38
41
  verbose: boolean;
@@ -186,7 +189,20 @@ function platformLabel(platform: NodeJS.Platform): string {
186
189
  }
187
190
 
188
191
  function safeTerminalValue(value: string): string {
189
- return value.replace(/[\u0000-\u001f\u007f]/gu, " ").trim().slice(0, 96);
192
+ return redactSecretString(value)
193
+ .replace(/[\u0000-\u001f\u007f]/gu, " ")
194
+ .replace(/\s+/gu, " ")
195
+ .trim()
196
+ .slice(0, 96);
197
+ }
198
+
199
+ function gatewayErrorDetail(value: string | undefined): string {
200
+ let detail = value?.trim() ?? "";
201
+ const prefix = "Could not start the Android Remote gateway";
202
+ while (new RegExp(`^${prefix}(?::|\\s|$)`, "iu").test(detail)) {
203
+ detail = detail.slice(prefix.length).replace(/^:\s*/u, "").trim();
204
+ }
205
+ return detail;
190
206
  }
191
207
 
192
208
  function defaultConfigureAndroidRemote(): { mode: "quick" | "named"; hostname?: string } {
@@ -275,8 +291,9 @@ async function waitForLiveProxy(
275
291
  function tunnelWaitMessage(status: OnboardRemoteStatus): string {
276
292
  const runtime = status.tunnel.runtime;
277
293
  if (status.gateway.status === "error") {
278
- return status.gateway.error
279
- ? `The Android gateway could not start: ${safeTerminalValue(status.gateway.error)}`
294
+ const detail = gatewayErrorDetail(status.gateway.error);
295
+ return detail
296
+ ? `The Android gateway could not start: ${safeTerminalValue(detail)}`
280
297
  : "The Android gateway could not start.";
281
298
  }
282
299
  if (runtime.error === "named_tunnel_incomplete") {
@@ -302,11 +319,13 @@ async function waitForVerifiedTunnel(
302
319
  now: () => number,
303
320
  timeoutMs: number,
304
321
  onTransition: (status: OnboardRemoteStatus["tunnel"]["runtime"]["status"]) => void,
322
+ retryGateway?: () => Promise<void>,
305
323
  ): Promise<OnboardRemoteStatus> {
306
324
  const deadline = now() + timeoutMs;
307
325
  let lastStatus: OnboardRemoteStatus | null = null;
308
326
  let lastReadError: unknown;
309
327
  let observed: OnboardRemoteStatus["tunnel"]["runtime"]["status"] | null = null;
328
+ let gatewayRetries = 0;
310
329
  do {
311
330
  try {
312
331
  const status = await read(baseUrl);
@@ -317,7 +336,27 @@ async function waitForVerifiedTunnel(
317
336
  observed = runtime.status;
318
337
  onTransition(runtime.status);
319
338
  }
320
- if (status.gateway.status === "error" || runtime.error === "named_tunnel_incomplete") {
339
+ if (status.gateway.status === "error") {
340
+ // The service can expose the main proxy before its Android listener has
341
+ // finished starting. A failed first attempt is also recoverable when a
342
+ // stale private app-server/socket is released a moment later. Re-run the
343
+ // idempotent enable operation a couple of times before surfacing a hard
344
+ // failure to the user.
345
+ if (retryGateway && gatewayRetries < GATEWAY_RETRY_LIMIT) {
346
+ gatewayRetries += 1;
347
+ try {
348
+ await retryGateway();
349
+ } catch (error) {
350
+ lastReadError = error;
351
+ }
352
+ const remainingAfterRetry = deadline - now();
353
+ if (remainingAfterRetry <= 0) break;
354
+ await sleep(Math.min(GATEWAY_RETRY_DELAY_MS, remainingAfterRetry));
355
+ continue;
356
+ }
357
+ throw new OnboardStepError(tunnelWaitMessage(status));
358
+ }
359
+ if (runtime.error === "named_tunnel_incomplete") {
321
360
  throw new OnboardStepError(tunnelWaitMessage(status));
322
361
  }
323
362
  if (runtime.mode === expectedMode
@@ -522,6 +561,10 @@ export async function runOnboard(
522
561
  else if (state === "checking") output.log(" Public address found · verifying…");
523
562
  else if (state === "error") output.log(" Waiting for Cloudflare to recover…");
524
563
  },
564
+ async () => {
565
+ if (!options.json) output.log(" Android gateway did not start; retrying…");
566
+ await applyAndroidRemote(baseUrl);
567
+ },
525
568
  );
526
569
  const publicUrl = verified.tunnel.runtime.publicUrl!;
527
570
  complete(6, "Public connection verified");
@@ -736,6 +736,26 @@ function systemdQuote(value: string): string {
736
736
  .replace(/%/g, "%%")}"`;
737
737
  }
738
738
 
739
+ /**
740
+ * `WorkingDirectory=` accepts a path value, not the quoted argument form used
741
+ * by `ExecStart=` and `Environment=`. Encode whitespace and unit-significant
742
+ * characters as systemd escapes so paths with spaces remain valid without
743
+ * leaving literal quotes in the directory name.
744
+ */
745
+ function systemdPath(value: string): string {
746
+ let escaped = "";
747
+ for (const character of value) {
748
+ if (character === "\\") escaped += "\\\\";
749
+ else if (character === "%") escaped += "%%";
750
+ else if (character === " ") escaped += "\\x20";
751
+ else if (character === "\t") escaped += "\\x09";
752
+ else if (character === "\n") escaped += "\\x0a";
753
+ else if (character === '"') escaped += "\\x22";
754
+ else escaped += character;
755
+ }
756
+ return escaped;
757
+ }
758
+
739
759
  function systemdEnvironment(name: string, value: string): string {
740
760
  return `Environment=${systemdQuote(`${name}=${value}`)}`;
741
761
  }
@@ -760,7 +780,7 @@ Wants=network-online.target
760
780
  [Service]
761
781
  Type=oneshot
762
782
  ExecStart=${systemdQuote(input.nodePath)} ${systemdQuote(input.launcherPath)} __auto-update
763
- WorkingDirectory=${systemdQuote(input.configDir)}
783
+ WorkingDirectory=${systemdPath(input.configDir)}
764
784
  ${env.join("\n")}
765
785
  TimeoutStartSec=15min
766
786