@yansigit/opencodex 2.36.1-dev.20260829.21 → 2.36.1-dev.20260829.32

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.
Files changed (32) hide show
  1. package/gui/dist/assets/ApiKeys-nJ-qJbkG.js +20 -0
  2. package/gui/dist/assets/Claude-Br34aNO2.js +2 -0
  3. package/gui/dist/assets/CodexSet-Bo2Vel9f.js +12 -0
  4. package/gui/dist/assets/FileIntegrationPage-8JuhUwT7.js +1 -0
  5. package/gui/dist/assets/Grok-pTPUqi3L.js +1 -0
  6. package/gui/dist/assets/Integrations-N-s59k0n.js +2 -0
  7. package/gui/dist/assets/IntegrationsOverview-C6Mkt8OU.js +3 -0
  8. package/gui/dist/assets/Logs-BzYAbD9a.js +1 -0
  9. package/gui/dist/assets/Models-8o4TdPzd.js +1 -0
  10. package/gui/dist/assets/NumberStepper-y1MLMfxu.js +1 -0
  11. package/gui/dist/assets/Providers-oTh_-wqc.js +1 -0
  12. package/gui/dist/assets/RestoreDialog-BnPA60nS.js +1 -0
  13. package/gui/dist/assets/Startup-eM7zbmU_.js +1 -0
  14. package/gui/dist/assets/Storage-Cuf1wakW.js +1 -0
  15. package/gui/dist/assets/Subagents-DEnwUJJx.js +1 -0
  16. package/gui/dist/assets/Usage-BMBOTm6l.js +1 -0
  17. package/gui/dist/assets/catalog-CerhMn14.js +1 -0
  18. package/gui/dist/assets/collapse-store-DnqZvhx0.js +1 -0
  19. package/gui/dist/assets/data-surface-Cq2fDI2w.js +1 -0
  20. package/gui/dist/assets/data-surface-D8RXShV2.js +1 -0
  21. package/gui/dist/assets/index-CEcmjvjC.js +12 -0
  22. package/gui/dist/assets/index-pLho_LBF.css +1 -0
  23. package/gui/dist/assets/intl-formatters-CTcuZoAe.js +1 -0
  24. package/gui/dist/assets/model-display-CTtXLqIv.js +1 -0
  25. package/gui/dist/assets/provider-payload-Bs3Sdqv7.js +1 -0
  26. package/gui/dist/assets/section-tabs-DEASco68.js +1 -0
  27. package/gui/dist/assets/shared-p0R307IX.js +69 -0
  28. package/gui/dist/index.html +3 -2
  29. package/package.json +1 -1
  30. package/src/generated/compatibility-version.json +1 -1
  31. package/gui/dist/assets/index-DLkXOXLC.css +0 -1
  32. package/gui/dist/assets/index-JGrKnrFw.js +0 -112
@@ -0,0 +1,20 @@
1
+ import{_ as e,c as t,h as n,m as r,n as i,s as a}from"./shared-p0R307IX.js";import{C as o,F as s,J as c,M as l,N as u,St as d,Y as f,g as p,lt as m,m as h,v as g,vt as _,yt as v}from"./index-CEcmjvjC.js";import{t as y}from"./data-surface-Cq2fDI2w.js";import{t as b}from"./data-surface-D8RXShV2.js";import{n as x,t as ee}from"./section-tabs-DEASco68.js";var S=e(n(),1);function C(e){return e?[`responses`,`chat`,`messages`]:[`responses`,`chat`]}function te(e){let t=e.id.indexOf(`/`),n=typeof e.owned_by==`string`&&e.owned_by.trim()?e.owned_by.trim():void 0,r=e.is_combo===!0?`combo`:t>0?e.id.slice(0,t):n??`openai`,i=t<0&&r===`openai`,a=r!==`openai`&&r!==`combo`;return{id:e.id,displayName:e.id,provider:r,native:i,custom:a}}function w(e){return e.id}function ne(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.ambiguous===!0||!(typeof t.requests7d!=`number`||!Number.isFinite(t.requests7d)||typeof t.totalRequests!=`number`||!Number.isFinite(t.totalRequests)||t.lastUsedAt!==void 0&&(typeof t.lastUsedAt!=`string`||Number.isNaN(new Date(t.lastUsedAt).getTime())))}var T=new Set([`required`,`accepted`,`rejected`]);function re(e){return Array.isArray(e)&&e.length>0&&e.every(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.endpoint==`string`&&T.has(t.bearer)&&T.has(t.dedicated)&&T.has(t.xApiKey)})}var E={baseUrl:`http://127.0.0.1:10100/v1`,responses:`http://127.0.0.1:10100/v1/responses`,chatCompletions:`http://127.0.0.1:10100/v1/chat/completions`,messages:`http://127.0.0.1:10100/v1/messages`,models:`http://127.0.0.1:10100/v1/models`};function ie(e){let t=e||E.responses,n=t.match(/^(.*)\/v1\/responses\/?$/),r=n?`${n[1]}/v1`:t.replace(/\/responses\/?$/,``);return{baseUrl:r,responses:t,chatCompletions:`${r}/chat/completions`,messages:`${r}/messages`,models:`${r}/models`}}function D(e,t){let n=new Date(e);return!e||Number.isNaN(n.getTime())?`—`:n.toLocaleDateString(t)}var O=d(),k=r();function A({url:e}){return(0,k.jsx)(j,{text:e,hintKey:`api.copyUrlHint`,copiedKey:`api.urlCopied`,className:`api-endpoint-url-btn`,children:(0,k.jsx)(`code`,{className:`api-code api-code-inline api-endpoint-url`,children:e})})}function j({text:e,hintKey:t,copiedKey:n,className:r,children:i}){let{t:o}=a(),s=(0,S.useId)(),c=(0,S.useRef)(null),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(!1),[p,m]=(0,S.useState)(null),h=(0,S.useRef)(null),g=l||d;(0,S.useEffect)(()=>()=>{h.current!==null&&window.clearTimeout(h.current)},[]),(0,S.useLayoutEffect)(()=>{if(!g)return;let e=()=>{let e=c.current;if(!e)return;let t=e.getBoundingClientRect();m({top:Math.max(8,t.top-8),left:t.left+t.width/2})};return e(),window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[g]);let _=()=>u(!0),v=()=>u(!1),y=async()=>{try{await navigator.clipboard.writeText(e),f(!0),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>f(!1),1500)}catch{f(!1)}},b=g&&p?(0,O.createPortal)((0,k.jsx)(`span`,{id:s,className:`ocx-tooltip-bubble api-copy-tip-fixed`,role:`tooltip`,style:{top:p.top,left:p.left},children:o(d?n:t)}),document.body):null,x={ref:c,className:`ocx-tooltip ${r}`,onMouseEnter:_,onMouseLeave:v,onFocus:_,onBlur:v,onClick:e=>{if(typeof window<`u`&&window.getSelection()?.toString())return;let t=e.target;if(t instanceof HTMLElement&&t!==e.currentTarget){let n=t.getBoundingClientRect();if(t.scrollHeight>t.clientHeight+1&&e.clientX>=n.right-16||t.scrollWidth>t.clientWidth+1&&e.clientY>=n.bottom-16)return}y()},onKeyDown:e=>{e.key===`Escape`&&v()},"aria-label":o(t),"aria-describedby":g?s:void 0};return(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,...x,children:i}),b]})}function M({text:e}){return(0,k.jsx)(j,{text:e,hintKey:`api.copyExampleHint`,copiedKey:`api.exampleCopied`,className:`api-example-copy-btn`,children:(0,k.jsx)(`code`,{className:`api-code api-example-pre`,children:e})})}function N(e,t){return t(e===`required`?`api.auth.required`:e===`accepted`?`api.auth.accepted`:`api.auth.rejected`)}function ae({endpoints:e,claudeCodeEnabled:t,authMatrix:n}){let{t:r}=a();return(0,k.jsxs)(`div`,{className:`panel api-panel`,children:[(0,k.jsx)(`h3`,{className:`panel-title`,children:r(`api.endpointsTitle`)}),(0,k.jsxs)(`div`,{className:`api-endpoints`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`muted small`,children:r(`api.baseUrl`)}),(0,k.jsx)(A,{url:e.baseUrl})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`muted small`,children:r(`api.responsesEndpoint`)}),(0,k.jsx)(A,{url:e.responses})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`muted small`,children:r(`api.chatCompletionsEndpoint`)}),(0,k.jsx)(A,{url:e.chatCompletions})]}),t&&(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`muted small`,children:r(`api.messagesEndpoint`)}),(0,k.jsx)(A,{url:e.messages})]}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`span`,{className:`muted small`,children:r(`api.modelsEndpoint`)}),(0,k.jsx)(A,{url:e.models})]})]}),(0,k.jsx)(`p`,{className:`muted small`,children:r(`api.endpointNote`)}),(0,k.jsxs)(`div`,{className:`api-auth-matrix-block`,children:[(0,k.jsx)(`h4`,{className:`api-auth-matrix-title`,children:r(`api.authTitle`)}),(0,k.jsx)(`div`,{className:`api-auth-matrix-scroll`,children:(0,k.jsxs)(`table`,{className:`api-auth-matrix`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:r(`api.auth.endpoint`)}),(0,k.jsx)(`th`,{children:(0,k.jsx)(`code`,{children:`Authorization: Bearer`})}),(0,k.jsx)(`th`,{children:(0,k.jsx)(`code`,{children:`x-opencodex-api-key`})}),(0,k.jsx)(`th`,{children:(0,k.jsx)(`code`,{children:`x-api-key`})})]})}),(0,k.jsx)(`tbody`,{children:n.map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:(0,k.jsx)(`code`,{children:e.endpoint})}),(0,k.jsx)(`td`,{children:N(e.bearer,r)}),(0,k.jsx)(`td`,{children:N(e.dedicated,r)}),(0,k.jsx)(`td`,{children:N(e.xApiKey,r)})]},e.endpoint))})]})}),(0,k.jsx)(`p`,{className:`muted small`,children:r(`api.authLoopback`)}),(0,k.jsx)(`p`,{className:`muted small`,children:r(`api.authBaseUrlNote`)})]})]})}function oe({keys:e,keysLoading:t=!1,keysLoadFailed:n,newName:r,creating:i,newKey:o,copied:s,confirmDelete:l,localeTag:u,showKeyList:d=!0,onNewNameChange:f,onCreate:p,onDismissNewKey:h,onCopyKey:g,onConfirmDelete:_,onCancelDelete:y,onDelete:b}){let{t:x}=a();return(0,k.jsxs)(k.Fragment,{children:[o&&(0,k.jsxs)(`div`,{className:`panel api-panel panel-accent api-newkey-panel`,children:[(0,k.jsx)(`h3`,{className:`panel-title`,children:x(`api.newKeyTitle`)}),(0,k.jsx)(`p`,{className:`muted small`,children:x(`api.newKeyNote`)}),(0,k.jsxs)(`div`,{className:`api-form-row`,children:[(0,k.jsx)(`code`,{className:`api-code`,style:{flex:1,wordBreak:`break-all`},children:o}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:g,children:s?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(c,{}),` `,x(`api.copied`)]}):x(`api.copy`)})]}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,style:{alignSelf:`flex-start`},onClick:h,children:x(`api.dismiss`)})]}),(0,k.jsxs)(`div`,{className:`panel api-panel api-generate-panel`,children:[(0,k.jsx)(`h3`,{className:`panel-title`,children:x(`api.generateTitle`)}),(0,k.jsxs)(`div`,{className:`api-form-row`,children:[(0,k.jsx)(`input`,{id:`api-key-name`,type:`text`,placeholder:x(`api.keyNamePlaceholder`),"aria-label":x(`api.keyNamePlaceholder`),value:r,maxLength:64,onChange:e=>f(e.target.value),className:`input`}),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-primary`,onClick:p,disabled:i,children:[(0,k.jsx)(m,{}),` `,x(i?`api.generating`:`api.generate`)]})]})]}),d&&(0,k.jsxs)(`div`,{className:`panel api-panel`,style:{marginTop:`1rem`},"aria-busy":t,children:[(0,k.jsx)(`h3`,{className:`panel-title`,children:t?x(`api.activeKeysLoading`):x(`api.activeKeys`,{count:e.length})}),t?(0,k.jsx)(`div`,{className:`api-active-keys-skeleton`,role:`status`,"aria-label":x(`common.loading`)}):e.length>0?(0,k.jsx)(`div`,{className:`tbl-wrap`,children:(0,k.jsxs)(`table`,{className:`tbl`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:x(`api.colName`)}),(0,k.jsx)(`th`,{children:x(`api.colKey`)}),(0,k.jsx)(`th`,{children:x(`api.colCreated`)}),(0,k.jsx)(`th`,{})]})}),(0,k.jsx)(`tbody`,{children:e.map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:e.name}),(0,k.jsx)(`td`,{children:(0,k.jsx)(`code`,{children:e.prefix})}),(0,k.jsx)(`td`,{children:D(e.createdAt,u)}),(0,k.jsx)(`td`,{children:l===e.id?(0,k.jsxs)(`span`,{className:`api-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-danger`,onClick:()=>b(e.id),children:x(`api.confirm`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:y,children:x(`common.cancel`)})]}):(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,"aria-label":x(`api.deleteAria`),onClick:()=>_(e.id),children:(0,k.jsx)(v,{})})})]},e.id))})]})}):n?(0,k.jsx)(`p`,{className:`muted`,children:x(`api.keysLoadFailed`)}):(0,k.jsx)(`p`,{className:`muted`,children:x(`api.noKeys`)})]})]})}function se({filteredModels:e,modelsLoading:t,modelsRefreshing:n=!1,modelsLoadFailed:r,modelCount:i,hasModelData:o,modelQuery:s,copiedModelId:c,modelTests:l,claudeCodeEnabled:u,onModelQueryChange:d,onCopyModelId:f,onTestModel:p,onRetryModels:m,canTestModels:h,sourceLabel:g,protocolLabel:_}){let{t:v}=a();return(0,k.jsxs)(`div`,{className:`panel api-panel api-models-panel`,children:[(0,k.jsxs)(`div`,{className:`api-panel-head`,children:[(0,k.jsx)(`h3`,{className:`panel-title`,children:v(`api.modelsTitle`)}),(0,k.jsx)(`span`,{className:`muted mono text-label`,children:v(`api.modelsCount`,{count:e.length})})]}),(0,k.jsx)(`p`,{className:`muted small`,children:v(`api.modelsSubtitle`)}),(0,k.jsx)(`input`,{type:`search`,className:`input`,value:s,onChange:e=>d(e.target.value),placeholder:v(`api.modelsSearch`),"aria-label":v(`api.modelsSearch`)}),r&&(0,k.jsxs)(`div`,{className:`api-models-error`,children:[(0,k.jsx)(`p`,{className:`muted small`,role:`alert`,children:v(`api.modelsLoadFailed`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:m,children:v(`common.retry`)})]}),n&&!t&&(0,k.jsx)(`p`,{className:`muted small`,"aria-live":`polite`,children:v(`api.modelsLoading`)}),t?(0,k.jsx)(b,{label:v(`api.modelsLoading`),rows:3}):o?e.length===0?(0,k.jsx)(`p`,{className:`muted small api-models-empty`,children:i===0?v(`api.modelsEmpty`):v(`api.modelsNoMatch`,{query:s.trim()})}):(0,k.jsx)(`div`,{className:`api-models-scroll`,children:(0,k.jsxs)(`table`,{className:`tbl`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:v(`api.colModel`)}),(0,k.jsx)(`th`,{children:v(`api.colSource`)}),(0,k.jsx)(`th`,{children:v(`api.colProtocols`)})]})}),(0,k.jsx)(`tbody`,{children:e.map(e=>{let t=w(e),n=C(u);return(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:(0,k.jsxs)(`div`,{className:`api-model-cell`,children:[(0,k.jsx)(`code`,{children:t}),e.displayName!==e.id&&(0,k.jsx)(`span`,{className:`muted small`,children:e.displayName})]})}),(0,k.jsx)(`td`,{children:g(e)}),(0,k.jsx)(`td`,{children:(0,k.jsxs)(`div`,{className:`api-model-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,onClick:()=>{f(t)},children:v(c===t?`api.modelCopied`:`api.copyModelId`)}),n.map(n=>{let r=l[t]?.[n],i=r?.state??`idle`;return(0,k.jsxs)(`span`,{className:`api-model-test-chip`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-ghost`,disabled:i===`testing`||!h,title:h?void 0:v(`api.auth.testNeedsFreshKey`),onClick:()=>{p(e,n)},children:v(`api.auth.testProtocol`,{protocol:_(n)})}),i!==`idle`&&(0,k.jsx)(`span`,{className:`api-test-note api-test-note--${i}`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:i===`testing`?v(`api.testingModel`):i===`ok`?v(`api.testSucceeded`):r?.detail??v(`api.testFailed`)})]},n)})]})})]},t)})})]})}):null]})}function ce({endpoints:e,claudeCodeEnabled:t}){let{t:n}=a(),r=JSON.stringify(n(`api.usageSampleInput`)),i=`curl ${e.chatCompletions} \\
2
+ -H "x-opencodex-api-key: ocx_YOUR_KEY_HERE" \\
3
+ -H "Content-Type: application/json" \\
4
+ -d '{
5
+ "model": "gpt-5.4",
6
+ "messages": [{"role": "user", "content": ${r}}]
7
+ }'`,o=`curl ${e.responses} \\
8
+ -H "x-opencodex-api-key: ocx_YOUR_KEY_HERE" \\
9
+ -H "Content-Type: application/json" \\
10
+ -d '{
11
+ "model": "gpt-5.4",
12
+ "input": ${r}
13
+ }'`,s=`curl ${e.messages} \\
14
+ -H "x-opencodex-api-key: ocx_YOUR_KEY_HERE" \\
15
+ -H "Content-Type: application/json" \\
16
+ -d '{
17
+ "model": "claude-sonnet-4-6",
18
+ "max_tokens": 64,
19
+ "messages": [{"role": "user", "content": ${r}}]
20
+ }'`;return(0,k.jsxs)(`section`,{className:`panel api-panel awi-usage-panel`,children:[(0,k.jsx)(`h3`,{className:`panel-title`,children:n(`api.workspace.usageExamples`)}),(0,k.jsxs)(`div`,{className:`awi-usage-panel-body`,children:[(0,k.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,k.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageChatTitle`)}),(0,k.jsx)(M,{text:i})]}),(0,k.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,k.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageResponsesTitle`)}),(0,k.jsx)(M,{text:o})]}),t&&(0,k.jsxs)(`div`,{className:`awi-usage-example`,children:[(0,k.jsx)(`h4`,{className:`awi-usage-example-title`,children:n(`api.usageMessagesTitle`)}),(0,k.jsx)(M,{text:s})]})]})]})}var P=[`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`,`dsh`,`mcode`,`zcode`,`prime`],F={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`,dsh:`api.clientConfig.clientDsh`,mcode:`api.clientConfig.clientMcode`,zcode:`api.clientConfig.clientZcode`,prime:`api.clientConfig.clientPrime`},I={opencode:`/provider-icons/opencode.svg`,pi:`/provider-icons/pi.svg`};function le({client:e,apiBase:n,onOpenDetails:r,onCopy:i,onDownload:a}){let o=t(),[s,c]=(0,S.useState)(0),l=[n,e,String(s)].join(`|`),[u,d]=(0,S.useState)(null);(0,S.useEffect)(()=>{let t=new AbortController,r=!1;return(async()=>{try{let i=await fetch(`${n}/api/client-config?client=${encodeURIComponent(e)}`,{signal:t.signal});if(!i.ok)throw Error(String(i.status));let a=await i.json();if(r)return;d({key:l,data:a,failed:!1})}catch{if(r)return;d({key:l,data:null,failed:!0})}})(),()=>{r=!0,t.abort()}},[n,e,l]);let f=u!==null&&u.key===l?u:null,p=f?.data??null,m=f?.failed??!1,h=f===null,g=o(F[e]),_=I[e],v=p?.text??``,y=(0,S.useCallback)(t=>{p&&r(e,p,v,t.currentTarget)},[e,p,v,r]);return(0,k.jsxs)(`li`,{className:`awi-clientconfig-row`,children:[(0,k.jsx)(`span`,{className:`awi-clientconfig-mark`,"aria-hidden":`true`,children:_?(0,k.jsx)(`img`,{src:_,alt:``,width:20,height:20}):(0,k.jsx)(`span`,{className:`awi-clientconfig-monogram`,children:g.slice(0,1)})}),(0,k.jsxs)(`span`,{className:`awi-clientconfig-identity`,children:[(0,k.jsx)(`span`,{className:`awi-clientconfig-name`,children:g}),(0,k.jsx)(`span`,{className:`muted text-label awi-clientconfig-meta`,children:h?o(`api.clientConfig.loading`):m||!p?(0,k.jsx)(`span`,{role:`alert`,children:o(`api.clientConfig.rowError`,{client:g})}):o(`api.clientConfig.rowMeta`,{destination:p.destination,count:p.modelCount})})]}),(0,k.jsx)(`span`,{className:`awi-clientconfig-row-actions`,children:m&&!h?(0,k.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>c(e=>e+1),children:o(`common.retry`)}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,"aria-label":o(`api.clientConfig.copyAria`,{client:g}),disabled:!p,onClick:()=>{p&&i(e,v)},children:o(`api.clientConfig.copy`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm`,"aria-label":o(`api.clientConfig.downloadAria`,{client:g}),disabled:!p,onClick:()=>{p&&a(e,p,v)},children:o(`api.clientConfig.download`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":o(`api.clientConfig.detailsAria`,{client:g}),disabled:!p,onClick:y,children:o(`api.clientConfig.details`)})]})})]})}function L({client:e,envelope:n,json:r,hasKeys:i,onClose:a,onCopy:o,onDownload:s}){let c=t(),l=(0,S.useRef)(null),u=`awi-clientconfig-dialog-${e}`;(0,S.useEffect)(()=>{let e=l.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]);let d=(0,S.useCallback)(e=>{e.preventDefault(),a()},[a]);return(0,k.jsxs)(`dialog`,{ref:l,className:`modal-overlay`,"aria-labelledby":u,onCancel:d,children:[(0,k.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":c(`common.close`),tabIndex:-1,onClick:a}),(0,k.jsxs)(`div`,{className:`modal-card awi-clientconfig-dialog`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,k.jsxs)(`div`,{className:`modal-head`,children:[(0,k.jsx)(`h3`,{id:u,children:c(F[e])}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:a,children:c(`common.close`)})]}),(0,k.jsx)(`pre`,{className:`api-code api-example-pre awi-clientconfig-json`,tabIndex:0,role:`group`,"aria-label":c(`api.clientConfig.jsonLabel`,{client:c(F[e])}),children:r}),(0,k.jsx)(`p`,{className:`muted small awi-clientconfig-count`,children:c(`api.clientConfig.modelCount`,{count:n.modelCount})}),n.modelsWithoutLimits>0&&(0,k.jsx)(`p`,{className:`muted small awi-clientconfig-degraded`,children:c(`api.clientConfig.missingLimits`,{count:n.modelsWithoutLimits,total:n.modelCount})}),!i&&(0,k.jsx)(`p`,{className:`muted small awi-clientconfig-nokey`,children:c(`api.clientConfig.noKeyYet`,{env:n.apiKeyEnv})}),(0,k.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,k.jsx)(`span`,{className:`muted text-label`,children:c(`api.clientConfig.destination`)}),(0,k.jsx)(M,{text:n.destination})]}),(0,k.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,k.jsx)(`span`,{className:`muted text-label`,children:c(`api.clientConfig.envHint`)}),(0,k.jsx)(M,{text:n.exportHint})]}),(0,k.jsx)(`p`,{className:`muted small awi-clientconfig-merge`,children:c(`api.clientConfig.mergeWarning`)}),(0,k.jsx)(`p`,{className:`muted text-label awi-clientconfig-where-title`,children:c(`api.clientConfig.whereDisclosure`)}),(0,k.jsx)(`p`,{className:`muted small`,children:c(`api.clientConfig.whereBody`)}),(0,k.jsxs)(`div`,{className:`modal-actions`,children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:o,children:c(`api.clientConfig.copy`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:s,children:c(`api.clientConfig.download`)})]})]})]})}function R({apiBase:e,baseUrl:n,hasKeys:r}){let i=t(),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(``),l=(0,S.useRef)(null);(0,S.useEffect)(()=>{if(a!==null)return;let e=l.current;e&&(l.current=null,e.isConnected&&e.focus())},[a]);let u=(0,S.useCallback)(async(e,t,n)=>{try{await navigator.clipboard.writeText(t),c(n?i(`api.clientConfig.copiedAnnounceClient`,{client:i(F[e])}):i(`api.clientConfig.copiedAnnounce`))}catch{c(i(`api.clientConfig.copyFailed`))}},[i]),d=(0,S.useCallback)((e,t,n)=>{let r=URL.createObjectURL(new Blob([n],{type:t.mediaType})),a=document.createElement(`a`);a.href=r,a.download=t.filename,a.click(),URL.revokeObjectURL(r),c(i(`api.clientConfig.downloadedAnnounce`,{filename:t.filename,destination:t.destination}))},[i]),f=(0,S.useCallback)(()=>o(null),[]),p=(0,S.useCallback)((e,t,n,r)=>{l.current=r,o({client:e,envelope:t,json:n})},[]);return(0,k.jsxs)(`section`,{className:`panel api-panel awi-clientconfig-panel`,children:[(0,k.jsx)(`div`,{className:`api-panel-head awi-clientconfig-head`,children:(0,k.jsx)(`h3`,{className:`panel-title`,children:i(`api.clientConfig.title`)})}),(0,k.jsx)(`ul`,{className:`awi-clientconfig-rows`,"aria-label":i(`api.clientConfig.rowsLabel`),children:P.map(t=>(0,k.jsx)(le,{client:t,apiBase:e,onOpenDetails:p,onCopy:(e,t)=>{u(e,t,!0)},onDownload:d},t))}),(0,k.jsxs)(`div`,{className:`awi-clientconfig-line`,children:[(0,k.jsx)(`span`,{className:`muted text-label`,children:i(`api.baseUrl`)}),(0,k.jsx)(M,{text:n})]}),(0,k.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:s}),a&&(0,k.jsx)(L,{client:a.client,envelope:a.envelope,json:a.json,hasKeys:r,onClose:f,onCopy:()=>{u(a.client,a.json,!1)},onDownload:()=>d(a.client,a.envelope,a.json)})]})}function ue({keys:e,keysLoading:n,keysLoadFailed:r,attributionSince:i,localeTag:a,busy:o,onSelect:s}){let c=t();return(0,k.jsxs)(`div`,{className:`panel api-panel awi-keylist-panel`,"aria-busy":n,children:[(0,k.jsx)(`div`,{className:`api-panel-head`,children:(0,k.jsx)(`h3`,{className:`panel-title`,children:n?c(`api.activeKeysLoading`):c(`api.activeKeys`,{count:e.length})})}),n?(0,k.jsx)(`div`,{className:`api-active-keys-skeleton`,role:`status`,"aria-label":c(`common.loading`)}):e.length===0?(0,k.jsx)(`p`,{className:`muted small`,children:c(r?`api.keysLoadFailed`:`api.noKeys`)}):(0,k.jsx)(`div`,{className:`tbl-wrap`,children:(0,k.jsxs)(`table`,{className:`tbl awi-keylist-table`,children:[(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:c(`api.colName`)}),(0,k.jsx)(`th`,{children:c(`api.colKey`)}),(0,k.jsx)(`th`,{children:c(`api.attribution.requests7d`)}),(0,k.jsx)(`th`,{children:c(`api.attribution.lastUsed`)})]})}),(0,k.jsx)(`tbody`,{children:e.map(e=>(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{children:(0,k.jsx)(`button`,{type:`button`,className:`awi-keylist-name`,disabled:o,onClick:()=>s(e.id),children:e.name})}),(0,k.jsx)(`td`,{children:(0,k.jsx)(`code`,{children:e.prefix})}),(0,k.jsx)(`td`,{children:i?e.usage.ambiguous?c(`api.attribution.railAmbiguous`):e.usage.requests7d.toLocaleString(a):c(`api.attribution.unavailable`)}),(0,k.jsx)(`td`,{children:!i||e.usage.ambiguous?`—`:e.usage.lastUsedAt?D(e.usage.lastUsedAt,a):c(`api.attribution.neverUsed`)})]},e.id))})]})})]})}function z({keys:e,apiBase:n,attributionSince:r,historyTruncated:i,authMatrix:a,keysLoading:o,keysLoadFailed:s,endpoints:c,claudeCodeEnabled:l,localeTag:u,newName:d,creating:p,newKey:m,copied:h,filteredModels:g,modelsLoading:v,modelsRefreshing:y=!1,modelsLoadFailed:b,modelCount:C,hasModelData:te,modelQuery:w,copiedModelId:ne,modelTests:T,canTestModels:re,onNewNameChange:E,onCreate:ie,onDismissNewKey:O,onCopyKey:A,onDelete:j,onRename:M,onModelQueryChange:N,onCopyModelId:P,onTestModel:F,onRetryModels:I,sourceLabel:le,protocolLabel:L}){let z=t(),[de,B]=(0,S.useState)(null),[V,fe]=(0,S.useState)(!1),[H,U]=(0,S.useState)(!1),[W,G]=(0,S.useState)(!1),[K,q]=(0,S.useState)(!1),[J,pe]=(0,S.useState)(``),[Y,me]=(0,S.useState)(!1),[he,X]=(0,S.useState)(!1),[ge,Z]=(0,S.useState)(!1),Q=de?e.find(e=>e.id===de)??null:null,_e=W||Y,ve=(0,S.useMemo)(()=>[{id:`keys`,label:z(`api.section.keys`),meta:o?void 0:String(e.length)},{id:`connect`,label:z(`api.section.connect`)},{id:`endpoints`,label:z(`api.section.endpoints`)},{id:`models`,label:z(`api.section.models`),meta:String(C)},{id:`examples`,label:z(`api.section.examples`)}],[z,e.length,o,C]),$=()=>{fe(!1),U(!1)},ye=()=>{B(null),$(),q(!1),X(!1),Z(!1)};(0,S.useEffect)(()=>{if(!V)return;let e=window.setTimeout(()=>U(!0),300);return()=>window.clearTimeout(e)},[V]);let be=()=>{Q&&fe(!0)},xe=async()=>{if(!(!Q||!H||W)){G(!0),Z(!1);try{await j(Q.id)?($(),B(null)):Z(!0)}finally{G(!1)}}},Se=()=>{Q&&(pe(Q.name),X(!1),q(!0))},Ce=async()=>{if(!Q||Y)return;let e=J.trim();if(!e||e===Q.name){q(!1);return}me(!0),X(!1);try{await M(Q.id,e)?q(!1):X(!0)}finally{me(!1)}};return(0,k.jsxs)(`div`,{className:`apikeys-workspace-shell`,children:[!Q&&(0,k.jsx)(ee,{scope:`api`,items:ve,ariaLabel:z(`api.workspace.sections`)}),(0,k.jsx)(`div`,{className:`apikeys-workspace-root`,children:(0,k.jsx)(`section`,{className:`apikeys-workspace-main`,"aria-label":z(`api.workspace.details`),children:Q?(0,k.jsxs)(`div`,{className:`awi-detail`,children:[(0,k.jsx)(`div`,{className:`awi-detail-toolbar`,children:(0,k.jsxs)(`button`,{type:`button`,className:`awi-back`,onClick:ye,disabled:_e,children:[(0,k.jsx)(f,{className:`awi-back-chevron`,"aria-hidden":`true`}),z(`modal.back`)]})}),(0,k.jsxs)(`div`,{className:`awi-detail-body`,children:[(0,k.jsxs)(`div`,{className:`awi-detail-head`,children:[(0,k.jsx)(`h2`,{className:`awi-detail-title`,children:Q.name}),(0,k.jsx)(`span`,{className:`awi-detail-actions`,children:V?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm awi-confirm-delete`,onClick:()=>{xe()},disabled:!H||W,children:[(0,k.jsx)(_,{}),` `,z(W?`api.key.deleting`:`api.confirm`)]},`confirm-delete`),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:$,disabled:W,children:z(`common.cancel`)})]}):(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:Se,disabled:K,children:z(`api.key.rename`)},`rename`),(0,k.jsxs)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:be,"aria-label":z(`api.deleteAria`),children:[(0,k.jsx)(_,{}),` `,z(`api.workspace.deleteKey`)]},`request-delete`)]})})]}),V&&(0,k.jsx)(`p`,{className:`muted awi-delete-hint`,children:z(`api.workspace.deleteConfirm`)}),ge&&(0,k.jsx)(`p`,{className:`awi-delete-error`,role:`alert`,children:z(`api.deleteFailed`)}),K&&(0,k.jsxs)(`div`,{className:`awi-rename`,children:[(0,k.jsx)(`label`,{className:`awi-rename-label`,htmlFor:`awi-key-name`,children:z(`api.key.name`)}),(0,k.jsx)(`input`,{id:`awi-key-name`,className:`input`,type:`text`,value:J,maxLength:64,disabled:Y,onChange:e=>pe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),Ce())}}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>{Ce()},disabled:Y,children:z(Y?`api.key.renaming`:`api.key.saveName`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>q(!1),disabled:Y,children:z(`common.cancel`)}),he&&(0,k.jsx)(`p`,{className:`awi-rename-error`,role:`alert`,children:z(`api.key.renameFailed`)})]}),(0,k.jsxs)(`div`,{className:`awi-section`,children:[(0,k.jsx)(`h3`,{className:`awi-section-title`,children:z(`api.workspace.keyDetails`)}),(0,k.jsxs)(`dl`,{className:`awi-kv`,children:[(0,k.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,k.jsx)(`dt`,{children:z(`api.workspace.keyPrefix`)}),(0,k.jsx)(`dd`,{children:(0,k.jsx)(`code`,{children:Q.prefix})})]}),(0,k.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,k.jsx)(`dt`,{children:z(`api.colCreated`)}),(0,k.jsx)(`dd`,{children:D(Q.createdAt,u)})]})]})]}),(0,k.jsxs)(`div`,{className:`awi-section`,children:[(0,k.jsx)(`h3`,{className:`awi-section-title`,children:z(`api.attribution.title`)}),r?Q.usage.ambiguous?(0,k.jsx)(`p`,{className:`muted`,children:z(`api.attribution.ambiguous`)}):(0,k.jsxs)(`dl`,{className:`awi-kv`,children:[(0,k.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,k.jsx)(`dt`,{children:z(`api.attribution.requests7d`)}),(0,k.jsx)(`dd`,{children:Q.usage.requests7d.toLocaleString(u)})]}),(0,k.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,k.jsx)(`dt`,{children:z(i?`api.attribution.totalRequestsAvailable`:`api.attribution.totalRequests`)}),(0,k.jsx)(`dd`,{children:Q.usage.totalRequests.toLocaleString(u)})]}),(0,k.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,k.jsx)(`dt`,{children:z(`api.attribution.lastUsed`)}),(0,k.jsx)(`dd`,{children:Q.usage.lastUsedAt?D(Q.usage.lastUsedAt,u):z(`api.attribution.neverUsed`)})]}),(0,k.jsxs)(`div`,{className:`awi-kv-row`,children:[(0,k.jsx)(`dt`,{children:z(i?`api.attribution.sinceAvailable`:`api.attribution.since`)}),(0,k.jsx)(`dd`,{children:D(r,u)})]})]}):(0,k.jsx)(`p`,{className:`muted`,children:z(`api.attribution.unavailableDetail`)})]})]})]}):(0,k.jsx)(`div`,{className:`awi-overview`,children:(0,k.jsxs)(`div`,{className:`awi-overview-section`,children:[(0,k.jsxs)(`div`,{id:x(`api`,`keys`),className:`awi-section-anchor`,children:[(0,k.jsx)(oe,{keys:e,keysLoading:o,keysLoadFailed:s,newName:d,creating:p,newKey:m,copied:h,confirmDelete:null,localeTag:u,showKeyList:!1,onNewNameChange:E,onCreate:ie,onDismissNewKey:O,onCopyKey:A,onConfirmDelete:()=>{},onCancelDelete:()=>{},onDelete:()=>{}}),(0,k.jsx)(ue,{keys:e,keysLoading:o,keysLoadFailed:s,attributionSince:r,localeTag:u,busy:_e,onSelect:e=>{B(e),$(),q(!1),X(!1),Z(!1)}})]}),(0,k.jsx)(`div`,{id:x(`api`,`connect`),className:`awi-section-anchor`,children:(0,k.jsx)(R,{apiBase:n,baseUrl:c.baseUrl,hasKeys:e.length>0})}),(0,k.jsx)(`div`,{id:x(`api`,`endpoints`),className:`awi-section-anchor`,children:(0,k.jsx)(ae,{endpoints:c,claudeCodeEnabled:l,authMatrix:a})}),(0,k.jsx)(`div`,{id:x(`api`,`models`),className:`awi-section-anchor`,children:(0,k.jsx)(se,{filteredModels:g,modelsLoading:v,modelsRefreshing:y,modelsLoadFailed:b,modelCount:C,hasModelData:te,modelQuery:w,copiedModelId:ne,modelTests:T,claudeCodeEnabled:l,onModelQueryChange:N,onCopyModelId:P,onTestModel:F,onRetryModels:I,canTestModels:re,sourceLabel:le,protocolLabel:L})}),(0,k.jsx)(`div`,{id:x(`api`,`examples`),className:`awi-section-anchor`,children:(0,k.jsx)(ce,{endpoints:c,claudeCodeEnabled:l})})]})})})})]})}var de=[],B=15e3;function V(e){let t=e.replace(/\/$/,``);if(!t)return E;try{return new URL(t).host?ie(`${t}/v1/responses`):E}catch{return E}}function fe(e){return!e||!re(e.authMatrix)||!Array.isArray(e.keys)||e.keys.some(e=>!e||!ne(e.usage))?null:e}function H({apiBase:e,active:t=!0}){let{t:n,locale:r}=a(),c=i.find(e=>e.code===r)?.htmlLang,d=`ocx.apikeys.list.v2:${e}`,f=`ocx.apikeys.models.v1:${e}`,m=`api-keys:${e}`,_=`api-models:${e}`,v=h(d),x=h(f),ee=fe(v?.data??null),C=x?.data??null,[T,D]=(0,S.useState)(null),[O,A]=(0,S.useState)(``),[j,M]=(0,S.useState)(null),[N,ae]=(0,S.useState)({}),[oe,se]=(0,S.useState)(``),[ce,P]=(0,S.useState)(!1),[F,I]=(0,S.useState)(null),[le,L]=(0,S.useState)(!1),R=(0,S.useRef)(!1),ue=(0,S.useCallback)(async t=>{let r=await fetch(`${e}/api/keys`,{signal:t}),i=await l(r);if(!i||!re(i.authMatrix))throw Error(n(`api.keysLoadFailed`));let a=i.keys??[];if(a.some(e=>!ne(e.usage)))throw Error(n(`api.keysLoadFailed`));let o=a,s=ie(i.endpoint??``),c={keys:o,endpoints:{baseUrl:i.baseUrl??s.baseUrl,responses:i.responsesEndpoint??i.endpoint??E.responses,chatCompletions:i.chatCompletionsEndpoint??s.chatCompletions,messages:i.messagesEndpoint??s.messages,models:i.modelsEndpoint??s.models},claudeCodeEnabled:i.claudeCodeEnabled!==!1,...i.attributionSince?{attributionSince:i.attributionSince}:{},...i.historyTruncated===!0?{historyTruncated:!0}:{},authMatrix:i.authMatrix};return p(d,c),c},[e,d,n]),H=(0,S.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 o=a.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`).map(e=>te(e)).sort((e,t)=>w(e).localeCompare(w(t)));return p(f,o),o},[e,f,n]),U=y(m,[e],ue,{isEmpty:e=>e.keys.length===0,initialData:ee??void 0,initialDataCachedAt:v?.cachedAt??null,staleAfterMs:6e4,enabled:t}),W=y(_,[e],H,{isEmpty:e=>e.length===0,initialData:C??void 0,initialDataCachedAt:x?.cachedAt??null,staleAfterMs:6e4,enabled:t}),G=U.state,K=W.state,q=G.data??ee,J=K.data??C??de,pe=q?.keys??[],Y=q?.endpoints??V(e),me=q?.claudeCodeEnabled??!0,he=q?.attributionSince,X=q?.historyTruncated===!0,ge=q?.authMatrix??[],Z=U.refresh,Q=W.refresh,_e=(0,S.useMemo)(()=>{let e=O.trim().toLowerCase();return e?J.filter(t=>w(t).toLowerCase().includes(e)||t.displayName.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)):J},[O,J]),ve=async t=>{if(R.current)return!1;R.current=!0,P(!0),D(null);try{let r=t??oe,i=await fetch(`${e}/api/keys`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:r||`default`})}),a=await u(i,n(`api.createFailed`));return typeof a?.key!=`string`||a.key.length===0?(D(n(`api.createFailed`)),!1):(I(a.key),se(``),Z(),!0)}catch{return D(n(`api.createFailed`)),!1}finally{R.current=!1,P(!1)}},$=async t=>{D(null);let n=g(B);try{return(await fetch(`${e}/api/keys`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t}),signal:n.signal})).ok?(Z(),!0):!1}catch{return!1}finally{n.clear()}},ye=async(t,n)=>{D(null);let r=g(B);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?(Z(),!0):!1}catch{return!1}finally{r.clear()}},be=async()=>{if(F){D(null);try{await navigator.clipboard.writeText(F),L(!0),window.setTimeout(()=>L(!1),2e3)}catch{L(!1),D(n(`api.key.copyFailed`))}}},xe=async e=>{try{await navigator.clipboard.writeText(e),M(e),window.setTimeout(()=>M(t=>t===e?null:t),2e3)}catch{}},Se=e=>e.native?n(`api.sourceNative`):e.provider===`combo`?n(`api.sourceCombo`):e.custom?n(`api.sourceCustom`):o(e.provider,n),Ce=e=>n(e===`responses`?`api.protocolResponses`:e===`messages`?`api.protocolMessages`:`api.protocolChatCompletions`),we=(e,t)=>e===`responses`?{url:Y.responses,body:{model:t,input:`ping`,max_output_tokens:1,stream:!1}}:e===`messages`?{url:Y.messages,body:{model:t,max_tokens:1,messages:[{role:`user`,content:`ping`}]}}:{url:Y.chatCompletions,body:{model:t,messages:[{role:`user`,content:`ping`}],max_tokens:1,stream:!1}},Te=(e,t,n)=>ae(r=>({...r,[e]:{...r[e],[t]:n}})),Ee=async(e,t)=>{if(!F)return;let r=w(e),i=we(t,r);Te(r,t,{state:`testing`});try{let e=await fetch(i.url,{method:`POST`,headers:{"Content-Type":`application/json`,"x-opencodex-api-key":F},body:JSON.stringify(i.body)});if(!e.ok){let n=await e.text();Te(r,t,{state:`error`,detail:n.slice(0,160)||String(e.status)});return}Te(r,t,{state:`ok`})}catch(e){Te(r,t,{state:`error`,detail:e instanceof Error?e.message:n(`api.testFailed`)})}},De=n(`api.subtitle`).split(`{authHeader}`);return(0,k.jsxs)(`section`,{className:`api-page`,"aria-busy":G.refreshing||K.refreshing||void 0,children:[(0,k.jsx)(`div`,{className:`page-head`,children:(0,k.jsx)(`h2`,{children:n(`api.title`)})}),(0,k.jsxs)(`p`,{className:`page-sub`,children:[De[0],(0,k.jsx)(`code`,{children:`x-opencodex-api-key`}),De[1]]}),T&&(0,k.jsx)(s,{tone:`err`,children:T}),G.showError&&q&&(0,k.jsx)(s,{tone:`err`,children:n(`api.keysLoadFailed`)}),G.showSkeleton&&!q?(0,k.jsx)(b,{label:n(`api.activeKeysLoading`),rows:4}):G.kind===`failed-cold`&&!q?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(s,{tone:`err`,children:G.error instanceof Error?G.error.message:n(`api.keysLoadFailed`)}),(0,k.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>Z(),children:n(`common.retry`)})]}):(0,k.jsx)(k.Fragment,{children:(0,k.jsx)(z,{keys:pe,apiBase:e,attributionSince:he,historyTruncated:X,authMatrix:ge,keysLoading:!1,keysLoadFailed:G.showError,endpoints:Y,claudeCodeEnabled:me,localeTag:c,newName:oe,creating:ce,newKey:F,copied:le,filteredModels:_e,modelsLoading:K.showSkeleton&&!K.data&&!C,modelsRefreshing:K.refreshing&&K.showError&&(K.data!==void 0||C!==null),modelsLoadFailed:K.showError,modelCount:J.length,hasModelData:K.data!==void 0||C!==null,modelQuery:O,copiedModelId:j,modelTests:N,onNewNameChange:se,onCreate:()=>{ve()},onDismissNewKey:()=>I(null),onCopyKey:()=>{be()},onDelete:$,onRename:ye,onModelQueryChange:A,onCopyModelId:e=>{xe(e)},onTestModel:(e,t)=>{Ee(e,t)},onRetryModels:()=>{Q({forceLoading:!0})},canTestModels:F!==null,sourceLabel:Se,protocolLabel:Ce})})]})}export{H as default};
@@ -0,0 +1,2 @@
1
+ import{_ as e,c as t,h as n,m as r,n as i,s as a}from"./shared-p0R307IX.js";import{B as o,F as s,H as c,I as l,L as u,M as ee,N as d,P as f,V as p,Y as m,g as h,lt as g,m as _,p as v,yt as y}from"./index-CEcmjvjC.js";import{t as te}from"./data-surface-Cq2fDI2w.js";import{t as ne}from"./data-surface-D8RXShV2.js";import{t as b}from"./model-display-CTtXLqIv.js";import{n as re,t as x}from"./collapse-store-DnqZvhx0.js";var S=e(n(),1);function C(e,t){let n=(e??[]).map(e=>({value:e,label:b(e)}));return[{value:``,label:t},...n]}function w(e){let t=e.autoConnectSupported===!0;return{autoConnectSupported:t,systemEnv:t&&e.systemEnv===!0}}function T(){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)}`}var ie=829800;function E(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`}var D=[`ANTHROPIC_MODEL`,`ANTHROPIC_DEFAULT_OPUS_MODEL`,`ANTHROPIC_DEFAULT_SONNET_MODEL`,`ANTHROPIC_DEFAULT_HAIKU_MODEL`,`ANTHROPIC_DEFAULT_FABLE_MODEL`];function O(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=D.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??829800}`]:[],...i,`claude`].join(`
2
+ `)}function k(e){return e?e.backend??`auto`:`inherit`}function A(e,t){if(t!==`inherit`)return t===`auto`?{...e,backend:void 0}:{...e,backend:t}}function j(e,t){return{...e,model:t}}function M(e){if(!e)return null;let t=(e.model??``).trim();return e.backend?{backend:e.backend,model:t}:t?{backend:null,model:t}:null}var N=r();function P({label:e,checked:t,onChange:n,disabled:r=!1,describedBy:i}){return(0,N.jsxs)(`label`,{className:`toggle`,children:[(0,N.jsx)(`input`,{type:`checkbox`,checked:t,disabled:r,"aria-label":e,"aria-describedby":i,onChange:e=>n(e.target.checked)}),(0,N.jsx)(`span`,{className:`slider`,"aria-hidden":`true`})]})}function F({supported:e,checked:n,onChange:r}){let i=t(),a=e?void 0:`claude-system-env-unsupported`;return(0,N.jsxs)(`div`,{className:`setting-row`,children:[(0,N.jsxs)(`div`,{className:`setting-label`,children:[(0,N.jsx)(`span`,{className:`title`,children:i(`claude.systemEnv`)}),e?(0,N.jsx)(`span`,{className:`desc`,children:i(`claude.systemEnvDesc`)}):(0,N.jsx)(`span`,{className:`desc`,id:a,children:(0,N.jsx)(c,{k:`claude.systemEnvUnsupported`,cmd:`ocx claude`})}),e&&n&&(0,N.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:i(`claude.systemEnvWarn`)})]}),(0,N.jsx)(P,{label:i(`claude.systemEnv`),checked:e&&n,disabled:!e,describedBy:a,onChange:r})]})}function ae({value:e,tierHaikuModel:n,options:r,onChange:i}){let a=t(),o=n??e;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:a(`claude.smallFastModelAccurateHint`)}),(0,N.jsx)(l,{value:e,options:r,onChange:i,label:a(`claude.smallFastModel`),style:{maxWidth:420}}),o===``&&(0,N.jsx)(`p`,{className:`notice-warn`,role:`status`,style:{marginTop:8},children:a(`claude.smallFastModelNativeWarning`)})]})}function oe(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 se({state:e,autoCompactOptions:n,availableModels:r,onStateChange:i}){let a=t();return(0,N.jsxs)(`div`,{className:`card`,style:{overflow:`hidden`},children:[(0,N.jsxs)(`div`,{className:`setting-row`,children:[(0,N.jsxs)(`div`,{className:`setting-label`,children:[(0,N.jsx)(`span`,{className:`title`,children:a(`claude.authMode`)}),(0,N.jsx)(`span`,{className:`desc`,children:a(`claude.authModeHint`)})]}),(0,N.jsx)(`div`,{className:`setting-controls`,children:(0,N.jsx)(l,{value:e.authMode,options:[{value:`auto`,label:a(`claude.authModeAuto`)},{value:`subscription`,label:a(`claude.authModeSubscription`)},{value:`proxy`,label:a(`claude.authModeProxy`)}],onChange:t=>i({...e,authMode:t}),label:a(`claude.authMode`),style:{minWidth:220},align:`right`,portal:!0})})]}),e.authModeOrigin&&(0,N.jsxs)(`div`,{className:`claude-effective-auth${e.authModeOrigin===`auto-unknown`?` warn`:``}`,role:`status`,children:[(0,N.jsx)(`span`,{className:`claude-effective-auth-label`,children:a(`claude.effectiveMode.label`)}),(0,N.jsxs)(`span`,{children:[e.authModeOrigin===`manual`?a(`claude.effectiveMode.manual`,{mode:e.markerMode===`proxy`?a(`claude.authModeProxy`):a(`claude.authModeSubscription`)}):e.authModeOrigin===`auto-present`?a(`claude.effectiveMode.autoPresent`,{source:oe(e.authFoundBy,a)}):e.authModeOrigin===`auto-absent`?a(`claude.effectiveMode.autoAbsent`):a(`claude.effectiveMode.autoUnknown`),e.admissionKeyActive===!0?` ${a(`claude.effectiveMode.admissionKey`)}`:``]})]}),(0,N.jsx)(F,{supported:e.autoConnectSupported,checked:e.systemEnv,onChange:t=>i({...e,systemEnv:t})}),(0,N.jsxs)(`div`,{className:`setting-row`,children:[(0,N.jsxs)(`div`,{className:`setting-label`,children:[(0,N.jsx)(`span`,{className:`title`,children:a(`claude.fastMode`)}),(0,N.jsx)(`span`,{className:`desc`,children:a(`claude.fastModeDesc`)})]}),(0,N.jsx)(`div`,{className:`setting-controls`,children:(0,N.jsx)(l,{value:e.fastMode===null?`auto`:e.fastMode?`on`:`off`,options:[{value:`auto`,label:a(`claude.fastAuto`)},{value:`on`,label:a(`claude.fastOn`)},{value:`off`,label:a(`claude.fastOff`)}],onChange:t=>i({...e,fastMode:t===`auto`?null:t===`on`}),label:a(`claude.fastMode`),style:{minWidth:140},align:`right`,portal:!0})})]}),(0,N.jsxs)(`div`,{className:`setting-row`,children:[(0,N.jsxs)(`div`,{className:`setting-label`,children:[(0,N.jsx)(`span`,{className:`title`,children:a(`claude.autoContext`)}),(0,N.jsx)(`span`,{className:`desc`,children:a(`claude.autoContextDesc`)}),e.maxContextTokens!==null&&(0,N.jsx)(`span`,{className:`desc`,style:{color:`var(--muted)`},children:a(`claude.autoContextInert`)})]}),(0,N.jsx)(P,{label:a(`claude.autoContext`),checked:e.autoContext,onChange:t=>i({...e,autoContext:t})})]}),e.autoContext&&(0,N.jsxs)(`div`,{className:`setting-row`,children:[(0,N.jsxs)(`div`,{className:`setting-label`,children:[(0,N.jsx)(`span`,{className:`title`,children:a(`claude.autoCompactWindow`)}),(0,N.jsx)(`span`,{className:`desc`,children:a(`claude.autoCompactWindowDesc`)}),e.autoCompactWindow!==null&&(0,N.jsx)(`span`,{className:`desc`,style:{color:`var(--red)`},children:a(`claude.autoCompactWindowWarn`)})]}),(0,N.jsx)(`div`,{className:`setting-controls`,children:(0,N.jsx)(l,{value:e.autoCompactWindow===null?``:String(e.autoCompactWindow),options:n,onChange:t=>i({...e,autoCompactWindow:t===``?null:Number(t)}),label:a(`claude.autoCompactWindow`),style:{minWidth:130},align:`right`,portal:!0})})]}),(0,N.jsxs)(`div`,{className:`setting-row`,children:[(0,N.jsxs)(`div`,{className:`setting-label`,children:[(0,N.jsx)(`span`,{className:`title`,children:a(`claude.injectAgents`)}),(0,N.jsx)(`span`,{className:`desc`,children:a(`claude.injectAgentsDesc`)})]}),(0,N.jsx)(P,{label:a(`claude.injectAgents`),checked:e.injectAgents,onChange:t=>i({...e,injectAgents:t})})]}),[`webSearchSidecar`,`visionSidecar`].map(t=>{let n=e[t],o=t===`webSearchSidecar`?`claude.webSearchSidecar`:`claude.visionSidecar`,s=t===`webSearchSidecar`?`claude.webSearchSidecarHint`:`claude.visionSidecarHint`,c=`claude-sidecar-models-${t}`;return(0,N.jsxs)(`div`,{className:`setting-row`,style:{alignItems:`flex-start`},children:[(0,N.jsxs)(`div`,{className:`setting-label setting-copy`,style:{flex:1},children:[(0,N.jsx)(`span`,{className:`title`,children:a(o)}),(0,N.jsx)(`span`,{className:`desc`,children:a(s)})]}),(0,N.jsxs)(`div`,{className:`setting-controls`,style:{display:`flex`,gap:8},children:[(0,N.jsx)(l,{value:k(n),options:[{value:`inherit`,label:a(`claude.useMainSetting`)},{value:`auto`,label:a(`dash.backendAuto`)},{value:`openai`,label:a(`dash.backendOpenAI`)},{value:`anthropic`,label:a(`dash.backendAnthropic`)}],onChange:r=>{i({...e,[t]:A(n,r)})},label:a(`dash.sidecarBackend`),portal:!0}),(0,N.jsx)(`input`,{className:`input mono`,value:n?.model??``,onChange:r=>{i({...e,[t]:j(n,r.target.value)})},placeholder:a(`claude.sidecarModelPlaceholder`),disabled:!n,list:n?c:void 0,"aria-label":a(`dash.sidecarModel`),style:{minWidth:210},autoComplete:`off`}),n&&(0,N.jsx)(`datalist`,{id:c,children:r.map(e=>(0,N.jsx)(`option`,{value:e},e))})]})]},t)})]})}function ce({manualEnv:e}){let n=t();return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:(0,N.jsx)(c,{k:`claude.quickstartHint`,cmd:`ocx claude`})}),(0,N.jsx)(`pre`,{className:`mono card`,style:{padding:`10px 14px`,overflowX:`auto`,margin:0},children:`ocx claude`}),(0,N.jsxs)(`details`,{style:{margin:`10px 0 0`},children:[(0,N.jsx)(`summary`,{className:`muted text-label`,style:{cursor:`pointer`,padding:`2px 2px`},children:n(`claude.manualEnv`)}),(0,N.jsx)(`pre`,{className:`mono card text-label`,style:{padding:`10px 14px`,overflowX:`auto`,margin:`6px 0 0`},children:e})]})]})}function le({rows:e,onRowsChange:n}){let r=t();return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`muted text-label`,style:{margin:`0 0 8px`},children:r(`claude.modelMapHint`)}),(0,N.jsx)(`div`,{className:`stack`,style:{gap:8},children:e.map((t,i)=>(0,N.jsxs)(`div`,{className:`row`,style:{gap:8},children:[(0,N.jsx)(`input`,{className:`input mono`,value:t.from,placeholder:r(`claude.mapFrom`),"aria-label":r(`claude.mapFrom`),onChange:t=>n(e.map((e,n)=>n===i?{...e,from:t.target.value}:e)),style:{flex:1}}),(0,N.jsx)(`span`,{className:`muted`,"aria-hidden":!0,children:`→`}),(0,N.jsx)(`input`,{className:`input mono`,value:t.to,placeholder:r(`claude.mapTo`),"aria-label":r(`claude.mapTo`),onChange:t=>n(e.map((e,n)=>n===i?{...e,to:t.target.value}:e)),style:{flex:1}}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>n(e.filter((e,t)=>t!==i)),"aria-label":r(`claude.removeMapping`),style:{color:`var(--red)`},children:(0,N.jsx)(y,{})})]},t.id))}),(0,N.jsx)(`div`,{style:{marginTop:8},children:(0,N.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>n([...e,{id:T(),from:``,to:``}]),children:[(0,N.jsx)(g,{}),` `,r(`claude.addMapping`)]})})]})}var I=`etc`;function L(e){let t=new Map;for(let n of e){let e=/\(([^)]+)\)\s*$/.exec(n.display_name),r=e?e[1]:I,i=t.get(r);i?i.push(n):t.set(r,[n])}return Array.from(t)}function R({aliases:e}){let n=t();return(0,N.jsxs)(`div`,{className:`claude-aliases`,children:[(0,N.jsx)(`p`,{className:`muted text-label claude-aliases-hint`,children:n(`claude.aliasesHint`)}),e.length===0?(0,N.jsx)(`div`,{className:`muted text-label`,children:n(`claude.none`)}):(0,N.jsx)(`div`,{className:`claude-aliases-scroll`,children:L(e).map(([e,t])=>(0,N.jsxs)(`div`,{className:`claude-aliases-group`,children:[(0,N.jsxs)(`div`,{className:`claude-aliases-group-label`,children:[e===I?n(`claude.aliasProviderOther`):e,(0,N.jsx)(`span`,{className:`claude-aliases-group-count`,children:t.length})]}),(0,N.jsx)(`div`,{className:`claude-aliases-chips`,children:t.map(e=>(0,N.jsxs)(`span`,{className:`claude-aliases-chip`,children:[(0,N.jsx)(`code`,{className:`claude-aliases-chip-id`,children:e.id}),e.display_name?(0,N.jsx)(`span`,{className:`claude-aliases-chip-name`,children:e.display_name}):null]},e.id))})]},e))})]})}function z({apiBase:e,active:n=!0}){let r=t(),{locale:o}=a(),c=i.find(e=>e.code===o)?.htmlLang??`en`,l=`ocx.claude-code.v1:${e}`,ee=`claude-code:${e}`,f=(0,S.useMemo)(()=>_(l),[l]),p=f?.data??null,[m,g]=(0,S.useState)(()=>p?.state??null),[v,y]=(0,S.useState)(()=>p?.rows??[]),[b,re]=(0,S.useState)(!!p),[x,D]=(0,S.useState)(``),[k,A]=(0,S.useState)(!1),[j,P]=(0,S.useState)(`settings`),[F,oe]=(0,S.useState)(!1),I=(0,S.useRef)(!1),L=(0,S.useCallback)(async t=>{let n=await fetch(`${e}/api/claude-code`,{signal:t}),i=await d(n,r(`claude.loadFail`));if(!i)throw Error(r(`claude.loadFail`));let a={...i,authMode:i.authMode===`proxy`||i.authMode===`subscription`?i.authMode:`auto`,...w(i),fastMode:i.fastMode??null,maxContextTokens:i.maxContextTokens??null,autoContext:i.autoContext!==!1,autoCompactWindow:i.autoCompactWindow??null,injectAgents:i.injectAgents!==!1,effectiveModelEnv:i.effectiveModelEnv??{}},o=Object.entries(i.modelMap??{}).map(([e,t])=>({id:T(),from:e,to:String(t)})),s={state:a,rows:o};if(t.aborted)throw Error(`Claude Code request aborted`);return g(a),y(o),re(!0),h(l,s),s},[e,l,r]),z=te(ee,[e],L,{isEmpty:()=>!1,enabled:n,initialData:p??void 0,initialDataCachedAt:f?.cachedAt??null,staleAfterMs:6e4}),B=z.state,V=B.data??p,H=m??V?.state??null,U=b?v:V?.rows??v,W=(0,S.useMemo)(()=>C(H?.available,r(`claude.smallFastModelUnsetOption`)),[H?.available,r]),G=(0,S.useMemo)(()=>{let e=[1e5,2e5,25e4,3e5,35e4,4e5,5e5,6e5,75e4,ie,9e5,1e6].sort((e,t)=>e-t),t=H?.autoCompactWindow??null,n=t!==null&&!e.includes(t)?[...e,t].sort((e,t)=>e-t):e;return[{value:``,label:r(`claude.autoCompactDefault`,{value:E(ie,c)})},...n.map(e=>({value:String(e),label:E(e,c)}))]},[H?.autoCompactWindow,r,c]),K=async()=>{if(!H||I.current)return;I.current=!0,oe(!0),D(``);let t=!H.enabled;try{let n=await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:t})});await d(n,r(`claude.saveFailed`)),g({...H,enabled:t}),z.refresh()}catch(e){A(!1),D(e instanceof Error&&e.message?e.message:r(`claude.networkError`))}finally{I.current=!1,oe(!1)}},ue=async()=>{if(!H)return;D(``);let t={};for(let e of U)e.from.trim()&&e.to.trim()&&(t[e.from.trim()]=e.to.trim());try{let n=await fetch(`${e}/api/claude-code`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:H.enabled,authMode:H.authMode,systemEnv:H.systemEnv,fastMode:H.fastMode,autoContext:H.autoContext,autoCompactWindow:H.autoCompactWindow,injectAgents:H.injectAgents,smallFastModel:H.smallFastModel,modelMap:t,webSearchSidecar:M(H.webSearchSidecar),visionSidecar:M(H.visionSidecar)})});await d(n,r(`claude.saveFailed`)),A(!0),D(r(`claude.saved`)),z.refresh()}catch(e){A(!1),D(e instanceof Error&&e.message?e.message:r(`claude.networkError`))}};if(B.kind===`disabled`&&!V)return null;if(B.showSkeleton&&!V)return(0,N.jsx)(ne,{label:r(`claude.loading`),rows:3});if(B.kind===`failed-cold`){let e=B.error instanceof Error?B.error.message:r(`claude.loadFail`);return(0,N.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[(0,N.jsx)(s,{tone:`err`,children:e}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>z.refresh(),children:r(`common.retry`)})]})}if(!H)return null;let q=[{id:`settings`,label:r(`claude.workspace.settings`),body:(0,N.jsx)(se,{state:H,autoCompactOptions:G,availableModels:H.available??[],onStateChange:g})},{id:`quickstart`,label:r(`claude.quickstart`),body:(0,N.jsx)(ce,{manualEnv:O(H)})},{id:`smallFast`,label:r(`claude.smallFastModel`),body:(0,N.jsx)(ae,{value:H.smallFastModel,tierHaikuModel:H.tierModels?.haiku,options:W,onChange:e=>g({...H,smallFastModel:e})})},{id:`modelMap`,label:r(`claude.modelMap`),meta:String(U.length),body:(0,N.jsx)(le,{rows:U,onRowsChange:e=>{re(!0),y(e)}})},{id:`aliases`,label:r(`claude.aliases`),meta:String(H.aliases.length),body:(0,N.jsx)(R,{aliases:H.aliases})}],J=q.find(e=>e.id===j)??q[0],Y=j===`settings`||j===`smallFast`||j===`modelMap`;return(0,N.jsxs)(`div`,{className:`claudecode-workspace-shell`,children:[x&&(0,N.jsx)(s,{tone:k?`ok`:`err`,children:x}),B.showError&&(0,N.jsx)(s,{tone:`err`,children:r(`claude.loadFail`)}),H&&(0,N.jsxs)(`div`,{className:`claudecode-connection-head`,children:[(0,N.jsx)(`span`,{id:`claudecode-connection-label`,children:r(`claude.enabledLabel`)}),(0,N.jsx)(u,{on:H.enabled,onClick:()=>void K(),disabled:F,label:r(`claude.toggleAria`)})]}),(0,N.jsxs)(`div`,{className:`claudecode-workspace-root`,children:[(0,N.jsx)(`aside`,{className:`claudecode-workspace-rail`,"aria-label":r(`claude.pageTitle`),children:(0,N.jsx)(`div`,{className:`claudecode-workspace-rail-list`,children:q.map(e=>(0,N.jsx)(`button`,{type:`button`,className:`claudecode-workspace-rail-row${j===e.id?` claudecode-workspace-rail-row--selected`:``}`,onClick:()=>P(e.id),"aria-current":j===e.id?`true`:void 0,children:(0,N.jsx)(`span`,{className:`claudecode-workspace-rail-name`,children:e.label})},e.id))})}),(0,N.jsxs)(`section`,{className:`claudecode-workspace-main`,"aria-label":J.label,children:[(0,N.jsxs)(`div`,{className:`ccw-main-head`,children:[(0,N.jsxs)(`h3`,{className:`ccw-main-title`,children:[J.label,J.meta==null?null:(0,N.jsx)(`span`,{className:`count`,children:J.meta})]}),(0,N.jsx)(`div`,{className:`claudecode-workspace-save`,"data-visible":Y?`true`:`false`,children:(0,N.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:!Y,tabIndex:Y?0:-1,"aria-hidden":!Y,onClick:()=>{ue()},children:r(`common.save`)})})]}),(0,N.jsx)(`div`,{className:`ccw-body`,children:J.body})]})]})]})}function B(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 V(e){return new Set(Object.keys(e))}function H(e,t){return t!==null&&e===t}var U=[`opus`,`fable`,`sonnet`,`haiku`],W=x(`ocx.claudeDesktop.collapsedFamilies.v2`),G={opus:`claudeDesktop.family.opus`,fable:`claudeDesktop.family.fable`,sonnet:`claudeDesktop.family.sonnet`,haiku:`claudeDesktop.family.haiku`};function K(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 ue(e){let t={...e.profile.assignments};for(let n of e.models){let e=t[n.route]??n.assignment;t[n.route]={family:U.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 q(e,t){return e&&typeof e==`object`&&`error`in e&&typeof e.error==`string`?e.error:t}function J(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 Y(e){return _(e)?.data??null}function de(e){return _(e)?.cachedAt??null}function fe(e){let t=Y(e);return{held:t,data:t?.data??null,profile:t?.profile??null,savedProfile:t?.profile?K(t.profile):null,destinations:t?.data?Object.fromEntries(t.data.models.map(e=>[e.route,t.profile.assignments[e.route]?.family??`opus`])):{}}}function pe({apiBase:e,active:t=!0,onPortChange:n}){let{t:r,locale:o}=a(),c=i.find(e=>e.code===o)?.htmlLang,l=`ocx.claude-desktop.v1:${e}`,u=`claude-desktop:${e}`,p=(0,S.useMemo)(()=>fe(l),[l]),[g,v]=(0,S.useState)(()=>p.profile),[y,b]=(0,S.useState)(()=>p.savedProfile),[x,C]=(0,S.useState)(()=>p.destinations),[w,T]=(0,S.useState)(null),[ie,E]=(0,S.useState)(``),[D,O]=(0,S.useState)(null),[k,A]=(0,S.useState)({}),[j,M]=(0,S.useState)({}),[P,F]=(0,S.useState)(()=>W.read()??new Set(U)),[ae,oe]=(0,S.useState)({}),se=(0,S.useRef)(null),ce=(0,S.useCallback)(async t=>{let n=await fetch(`${e}/api/claude-desktop`,{signal:t}),i=await d(n,r(`claudeDesktop.loadFail`));if(!i||!(`profile`in i)||!(`models`in i))throw Error(q(i,r(`claudeDesktop.loadFail`)));let a=ue(i),o={data:i,profile:a};if(t.aborted)throw Error(`Claude Desktop request aborted`);if(v(a),b(K(a)),C(Object.fromEntries(i.models.map(e=>[e.route,a.assignments[e.route]?.family??`opus`]))),W.read()===null){let e=Object.fromEntries(U.map(e=>[e,0]));for(let t of i.models)e[a.assignments[t.route]?.family??`opus`]+=1;F(V(e))}return h(l,o),o},[e,l,r,C,v,b]),le=te(u,[e],ce,{isEmpty:()=>!1,enabled:t,initialData:p.held??void 0,initialDataCachedAt:de(l),staleAfterMs:6e4}),I=le.state,L=I.data??(p.data&&p.profile?{data:p.data,profile:p.profile}:null),R=L?.data??null,z=g??L?.profile??null,Y=y??L?.profile??null,pe=L?Object.fromEntries(L.data.models.map(e=>[e.route,L.profile.assignments[e.route]?.family??`opus`])):{},me=Object.keys(x).length>0?x:pe;(0,S.useEffect)(()=>{if(n){if(typeof R?.port==`number`){n(R.port);return}I.kind===`failed-cold`&&n(null)}},[R?.port,I.kind,n]);let X=(0,S.useMemo)(()=>z!==null&&Y!==null&&JSON.stringify(z)!==JSON.stringify(Y),[z,Y]),Z=(0,S.useMemo)(()=>{let e=Object.fromEntries(U.map(e=>[e,[]]));if(!R||!z)return e;for(let t of R.models)e[z.assignments[t.route]?.family??`opus`].push(t);return e},[R,z]),he=(0,S.useMemo)(()=>{let e={};for(let t of U){let n=Z[t].filter(e=>e.available).map(e=>e.route).sort(),r=z?.defaults[t]??null;e[t]=r&&n.includes(r)?r:n[0]??null}return e},[Z,z]),ge=`ocx.claude-desktop.status.v1:${e}`,_e=`claude-desktop-status:${e}`,ve=_(ge),ye=te(_e,[e],async t=>{let n=await fetch(`${e}/api/claude-desktop/status`,{signal:t}),r=await ee(n);if(!r)throw Error(`Claude Desktop status unavailable`);return h(ge,r),r},{isEmpty:()=>!1,pollMs:5e3,enabled:t,initialData:ve?.data??void 0}),be=ye.state,Q=be.data??ve?.data??null,$=be.showError,xe=(e,t)=>{!z||z.assignments[e]?.family===t||(v(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}}),C(n=>({...n,[e]:t})),E(r(`claudeDesktop.moved`,{route:e,family:r(G[t])})))},Se=e=>{let t=re(P,e);W.write(t),F(t)},Ce=async t=>{if(!(!z||D)){O(`save`),T(null);try{let n=await fetch(`${e}/api/claude-desktop`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({profile:z})});if(await d(n,r(`claudeDesktop.saveFailed`)),b(K(z)),t){O(`apply`);let t=await fetch(`${e}/api/claude-desktop/apply`,{method:`POST`});(await d(t,r(`claudeDesktop.applyFailed`)))?.saved===!1?(T({tone:`warn`,text:r(`claudeDesktop.appliedMarkerUnsaved`)}),E(r(`claudeDesktop.appliedMarkerUnsaved`))):(T({tone:`ok`,text:r(`claudeDesktop.savedApplied`)}),E(r(`claudeDesktop.savedAppliedAnnounce`)))}else T({tone:`ok`,text:r(`claudeDesktop.saved`)}),E(r(`claudeDesktop.savedAnnounce`));ye.refresh()}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.updateFailed`);T({tone:`err`,text:t}),E(t)}finally{O(null)}}},we=()=>{if(!z)return;let e=URL.createObjectURL(new Blob([`${JSON.stringify(z,null,2)}\n`],{type:`application/json`})),t=document.createElement(`a`);t.href=e,t.download=`claude-desktop-profile.json`,t.click(),URL.revokeObjectURL(e),E(r(`claudeDesktop.exported`))},Te=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=ue({...R,profile:e});v(n),T({tone:`ok`,text:r(`claudeDesktop.importReady`)}),E(r(`claudeDesktop.importedAnnounce`))}catch(e){let t=e instanceof Error?e.message:r(`claudeDesktop.importInvalid`);T({tone:`err`,text:t}),E(r(`claudeDesktop.importFailed`,{error:t}))}},Ee=(e,t)=>{e.preventDefault();let n=e.dataTransfer.getData(`text/plain`);n&&xe(n,t)};if(I.kind===`disabled`&&!L)return null;if(I.showSkeleton&&!L)return(0,N.jsx)(ne,{label:r(`claudeDesktop.loading`),rows:4});if(I.kind===`failed-cold`){let e=I.error instanceof Error?I.error.message:r(`claudeDesktop.loadFail`);return(0,N.jsxs)(`div`,{className:`claude-desktop-error`,children:[(0,N.jsx)(s,{tone:`err`,children:e}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>le.refresh(),children:r(`claudeDesktop.retry`)})]})}return!R||!z?null:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`claude-desktop-toolbar`,children:(0,N.jsxs)(`div`,{className:`claude-profile-tools`,children:[(0,N.jsx)(`input`,{ref:se,type:`file`,accept:`application/json,.json`,hidden:!0,onChange:e=>void Te(e)}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>se.current?.click(),children:r(`claudeDesktop.importJson`)}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:we,children:r(`claudeDesktop.exportJson`)})]})}),(0,N.jsxs)(`div`,{className:`claude-status-bar ${$&&!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&&!$||void 0,children:[(0,N.jsx)(`span`,{className:`claude-status-dot`}),(0,N.jsx)(`span`,{children:$&&!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,N.jsxs)(`span`,{className:`claude-status-health`,children:[r(`claudeDesktop.health.lastRequest`),`:`,` `,new Date(Q.health.lastRequestAt).toLocaleTimeString(c)]}),Q&&Q.health.requestCount>0&&(0,N.jsx)(`span`,{className:`claude-status-health`,children:r(`claudeDesktop.health.stats`,{count:Q.health.requestCount,errors:Q.health.errorCount})})]}),(0,N.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:ie}),w&&(0,N.jsx)(s,{tone:w.tone,children:w.text}),I.showError&&(0,N.jsx)(s,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),$&&Q&&(0,N.jsx)(s,{tone:`err`,children:r(`claudeDesktop.loadFail`)}),(0,N.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,N.jsx)(`span`,{className:`claude-dirty${X?` active`:``}`,children:r(X?`claudeDesktop.unsaved`:`claudeDesktop.upToDate`)}),(0,N.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,N.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!X||D!==null,onClick:()=>void Ce(!1),children:r(D===`save`?`claudeDesktop.saving`:`common.save`)}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:D!==null,onClick:()=>void Ce(!0),children:D===`apply`?r(`claudeDesktop.applying`):D===`save`?r(`claudeDesktop.saving`):Q?.desiredEnabled===!1?r(`claudeDesktop.enableApply`):r(`claudeDesktop.saveApply`)})]})]}),R.models.length===0&&(0,N.jsx)(f,{title:r(`claudeDesktop.emptyTitle`),children:r(`claudeDesktop.emptyHint`)}),(0,N.jsx)(`div`,{className:`ocx-group-stack`,"aria-label":r(`claudeDesktop.assignmentsLabel`),children:U.map(e=>{let t=Z[e],n=B(t,k[e]??``,j[e]??6),i=P.has(e),a=he[e];return(0,N.jsxs)(`section`,{className:`ocx-group${i?` collapsed`:``}`,"aria-labelledby":`claude-lane-${e}`,onDragOver:e=>e.preventDefault(),onDrop:t=>Ee(t,e),children:[(0,N.jsxs)(`header`,{className:`ocx-group-head${i?``:` open`}`,children:[(0,N.jsx)(`h3`,{id:`claude-lane-${e}`,className:`ocx-group-heading`,children:(0,N.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!i,"aria-controls":`claude-lane-body-${e}`,onClick:()=>Se(e),children:[(0,N.jsx)(m,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:i?`none`:`rotate(90deg)`}}),(0,N.jsx)(`span`,{className:`ocx-group-name`,children:r(G[e])}),(0,N.jsx)(`span`,{className:`ocx-group-count`,children:r(t.length===1?`claudeDesktop.modelCountOne`:`claudeDesktop.modelCountMany`,{count:t.length})}),a&&(0,N.jsx)(`code`,{className:`claude-lane-default`,title:a,children:a})]})}),t.length>0&&z.defaults[e]===null&&(0,N.jsx)(`span`,{className:`claude-default-needed`,children:r(`claudeDesktop.chooseDefault`)}),a&&a!==z.defaults[e]&&(0,N.jsx)(`span`,{className:`claude-default-needed`,title:a,children:r(`claudeDesktop.temporaryDefault`)})]}),!i&&(0,N.jsxs)(`div`,{id:`claude-lane-body-${e}`,children:[n.showSearch&&(0,N.jsx)(`input`,{className:`input claude-lane-search`,type:`search`,placeholder:r(`models.search`),"aria-label":r(`models.search`),value:k[e]??``,onChange:t=>{let n=t.target.value;A(t=>({...t,[e]:n})),M(t=>({...t,[e]:6}))}}),(0,N.jsxs)(`div`,{className:`claude-lane-models`,children:[t.length===0?(0,N.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneEmpty`)}):n.noMatch?(0,N.jsx)(`div`,{className:`claude-lane-empty`,children:r(`claudeDesktop.laneNoMatch`)}):n.shown.map(t=>{let n=z.assignments[t.route],i=J(t.contextWindow,r),a=me[t.route]??`opus`,o=ae[t.route]??H(t.route,he[e]);return(0,N.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,N.jsxs)(`button`,{type:`button`,className:`claude-model-summary`,"aria-expanded":o,"aria-controls":`claude-model-body-${t.route}`,onClick:()=>oe(e=>({...e,[t.route]:!o})),children:[(0,N.jsx)(m,{className:`ocx-chevron`,width:12,height:12,"aria-hidden":`true`,style:{transform:o?`rotate(90deg)`:`none`}}),(0,N.jsxs)(`span`,{className:`claude-model-names`,children:[(0,N.jsx)(`strong`,{title:t.label,children:t.label}),(0,N.jsx)(`code`,{title:t.route,children:t.route})]}),i&&(0,N.jsx)(`span`,{className:`claude-model-context`,children:i}),!i&&(0,N.jsx)(`span`,{className:`claude-model-context claude-model-context-unknown`,children:r(`claudeDesktop.contextUnknown`)}),t.supports1m===!0&&(0,N.jsx)(`span`,{className:`claude-1m-chip`,children:r(`claudeDesktop.supports1m`)}),t.effortSupported===!1&&(0,N.jsx)(`span`,{className:`claude-effort-badge off`,children:r(`claudeDesktop.effort.displayOnly`)}),t.effortSupported===!0&&(0,N.jsx)(`span`,{className:`claude-effort-badge on`,children:r(`claudeDesktop.effort.supported`)}),z.defaults[e]===t.route&&(0,N.jsx)(`span`,{className:`claude-row-default`,children:r(`claudeDesktop.defaultBadge`)}),(0,N.jsx)(`span`,{className:`badge ${t.available?`badge-green`:`badge-muted`}`,children:t.available?r(`claudeDesktop.available`):r(`claudeDesktop.unavailable`)})]}),o&&(0,N.jsxs)(`div`,{className:`claude-model-body`,id:`claude-model-body-${t.route}`,children:[he[e]===t.route&&z.defaults[e]!==t.route&&(0,N.jsx)(`span`,{className:`claude-effective-default`,children:r(`claudeDesktop.temporaryDefault`)}),(0,N.jsxs)(`div`,{className:`claude-field`,children:[(0,N.jsx)(`span`,{children:r(`claudeDesktop.alias`)}),(0,N.jsx)(`code`,{className:`claude-alias`,title:n.alias,children:n.alias})]}),(0,N.jsxs)(`label`,{className:`claude-default-radio`,children:[(0,N.jsx)(`input`,{type:`radio`,name:`default-${e}`,checked:z.defaults[e]===t.route,disabled:!t.available,onChange:()=>v(n=>n&&{...n,defaults:{...n.defaults,[e]:t.route}})}),r(`claudeDesktop.useAsDefault`,{family:r(G[e])})]}),(0,N.jsxs)(`div`,{className:`claude-move-row`,children:[(0,N.jsx)(`label`,{htmlFor:`move-${t.route}`,children:r(`claudeDesktop.moveTo`)}),(0,N.jsx)(`select`,{id:`move-${t.route}`,className:`input`,value:a,disabled:!t.available,onChange:e=>C(n=>({...n,[t.route]:e.target.value})),children:U.map(e=>(0,N.jsx)(`option`,{value:e,children:r(G[e])},e))}),(0,N.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,disabled:!t.available||a===e,onClick:()=>xe(t.route,a),children:r(`claudeDesktop.move`)})]})]})]},t.route)}),n.hidden>0&&(0,N.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm claude-lane-more`,onClick:()=>M(t=>({...t,[e]:(t[e]??6)+6})),children:r(`models.showMore`,{n:n.hidden})})]})]})]},e)})})]})}var me=`integrations/claude`,X=`integrations/claude/desktop`;function Z(e=typeof window<`u`?window.location.hash:``){return p(e)===X?`desktop`:`code`}function he(e){let t=v(`ocx.claude-desktop.v1:${e}`);return typeof t?.data?.port==`number`?t.data.port:null}function ge({apiBase:e,active:n=!0}){let[r,i]=(0,S.useState)(Z),a=t(),s=(0,S.useRef)(null),c=(0,S.useRef)(null),l=he(e),[u,ee]=(0,S.useState)(null),d=u?.base===e?u.port:l,f=u?.base===e,p=(0,S.useCallback)(t=>{ee(n=>n?.base===e&&n.port===t?n:{base:e,port:t})},[e]);(0,S.useEffect)(()=>{let e=()=>i(Z());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let m=e=>{o(e===`desktop`?X:me),i(e),window.requestAnimationFrame(()=>{(e===`code`?s:c).current?.focus({preventScroll:!0})})},h=e=>{e.key===`ArrowLeft`||e.key===`ArrowRight`?(e.preventDefault(),m(r===`code`?`desktop`:`code`)):e.key===`Home`?(e.preventDefault(),m(`code`)):e.key===`End`&&(e.preventDefault(),m(`desktop`))};return(0,N.jsxs)(`section`,{className:`claude-page`,children:[(0,N.jsxs)(`div`,{className:`claude-page-intro`,children:[(0,N.jsx)(`div`,{className:`page-head`,children:(0,N.jsx)(`h2`,{children:a(r===`code`?`claude.pageTitle`:`claudeDesktop.title`)})}),r===`code`?(0,N.jsx)(`p`,{className:`page-sub`,children:a(`claude.subtitle`)}):(0,N.jsx)(`p`,{className:`page-sub`,children:d==null?a(f?`claudeDesktop.loadFail`:`claudeDesktop.loading`):a(`claudeDesktop.subtitle`,{port:d})})]}),(0,N.jsxs)(`div`,{className:`claude-tabs`,role:`tablist`,"aria-label":a(`claude.tabsLabel`),children:[(0,N.jsx)(`button`,{type:`button`,role:`tab`,ref:s,"aria-selected":r===`code`,"aria-controls":`claude-code-panel`,id:`claude-code-tab`,className:r===`code`?`active`:``,tabIndex:r===`code`?0:-1,onKeyDown:h,onClick:()=>m(`code`),children:a(`claude.tabCode`)}),(0,N.jsx)(`button`,{type:`button`,role:`tab`,ref:c,"aria-selected":r===`desktop`,"aria-controls":`claude-desktop-panel`,id:`claude-desktop-tab`,className:r===`desktop`?`active`:``,tabIndex:r===`desktop`?0:-1,onKeyDown:h,onClick:()=>m(`desktop`),children:a(`claude.tabDesktop`)})]}),(0,N.jsx)(`div`,{id:`claude-code-panel`,role:`tabpanel`,"aria-labelledby":`claude-code-tab`,hidden:r!==`code`,children:(0,N.jsx)(z,{apiBase:e,active:n&&r===`code`},e)}),(0,N.jsx)(`div`,{id:`claude-desktop-panel`,role:`tabpanel`,"aria-labelledby":`claude-desktop-tab`,hidden:r!==`desktop`,children:(0,N.jsx)(pe,{apiBase:e,active:n&&r===`desktop`,onPortChange:p},e)})]})}export{ge as default};
@@ -0,0 +1,12 @@
1
+ import{_ as e,c as t,h as n,m as r}from"./shared-p0R307IX.js";import{B as i,N as a,_ as o,bt as s,h as c,p as l,v as u}from"./index-CEcmjvjC.js";import{t as d}from"./data-surface-Cq2fDI2w.js";import{n as f,t as p}from"./data-surface-D8RXShV2.js";import{a as m,c as h,s as g,t as _}from"./provider-payload-Bs3Sdqv7.js";var v=e(n(),1),y=r(),b=`/api/codex-auth/features/default-mode-request-user-input`;function x({apiBase:e}){let n=t(),[r,i]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=(0,v.useRef)(!1),_=(0,v.useRef)(!1),x=(0,v.useRef)(0),S=(0,v.useCallback)(async()=>{if(g.current)return;let t=++x.current,n=u(15e3);try{let r=await fetch(`${e}${b}`,{signal:n.signal});if(!r.ok)throw Error(`load`);let a=await r.json();if(g.current||t!==x.current)return;_.current=a.enabled===!0,i(_.current),c(!0),p(!1)}catch{!g.current&&t===x.current&&p(!0)}finally{n.clear()}},[e]);(0,v.useEffect)(()=>{let e=window.setTimeout(()=>{S()},0),t=o(()=>{S()},3e4);return()=>{window.clearTimeout(e),t()}},[S]);let C=(0,v.useCallback)(async()=>{if(g.current||!s||f)return;let t=!_.current,r=_.current;_.current=t,i(t),g.current=!0,d(!0),h(null),x.current++;try{let r=await fetch(`${e}${b}`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:t})}),o=await a(r)??{};if(o.ok!==!0)throw Error(String(r.status));_.current=o.enabled===!0,i(_.current),c(!0),h({tone:`ok`,message:n(o.changed===!0?`codexAuth.requestUserInputUpdatedRestart`:`codexAuth.requestUserInputUpdated`)})}catch(e){_.current=r,i(r);let t=e instanceof Error&&e.message&&!/^HTTP \d{3}$/.test(e.message)?e.message:n(`codexAuth.requestUserInputUpdateFailed`);h({tone:`err`,message:t})}finally{g.current=!1,d(!1)}},[e,s,f,n]),w=l||!s||f;return(0,y.jsxs)(`div`,{className:`card card-row codex-request-user-input-card`,style:{marginTop:16},"aria-busy":l||!s&&!f||void 0,children:[(0,y.jsxs)(`div`,{className:`codex-request-user-input-copy`,children:[(0,y.jsx)(`strong`,{children:n(`codexAuth.requestUserInput`)}),(0,y.jsx)(`div`,{className:`card-sub`,role:f?`alert`:void 0,children:n(f?`codexAuth.requestUserInputLoadFailed`:`codexAuth.requestUserInputDesc`)}),(0,y.jsx)(`code`,{className:`mono codex-request-user-input-config`,children:`[features]
2
+ default_mode_request_user_input = true`})]}),(0,y.jsxs)(`div`,{className:`codex-request-user-input-controls`,children:[f&&(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>{S()},children:n(`common.retry`)}),(0,y.jsx)(`button`,{type:`button`,className:`toggle ${r?`on`:``}`,onClick:()=>{C()},disabled:w,"aria-pressed":r,"aria-label":n(`codexAuth.requestUserInput`),title:n(`codexAuth.requestUserInput`),children:(0,y.jsx)(`span`,{className:`toggle-knob`})})]}),m&&(0,y.jsx)(`div`,{className:`codex-request-user-input-feedback${m.tone===`err`?` is-error`:``}`,role:m.tone===`err`?`alert`:`status`,"aria-atomic":`true`,children:m.message})]})}function S({apiBase:e}){let n=t(),[r,i]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=(0,v.useRef)(!1),_=(0,v.useRef)(!1),b=(0,v.useRef)(0),x=(0,v.useCallback)(async()=>{if(_.current)return;let t=++b.current,n=u(15e3);try{let r=await fetch(`${e}/api/settings`,{signal:n.signal});if(!r.ok)throw Error(`load`);let a=await r.json();if(_.current||t!==b.current)return;if(typeof a.codexAccountPickerEnabled!=`boolean`)throw Error(`shape`);g.current=a.codexAccountPickerEnabled,i(a.codexAccountPickerEnabled),c(!0),p(!1)}catch{!_.current&&t===b.current&&p(!0)}finally{n.clear()}},[e]);(0,v.useEffect)(()=>{let e=window.setTimeout(()=>{x()},0),t=o(()=>{x()},3e4);return()=>{window.clearTimeout(e),t()}},[x]);let S=(0,v.useCallback)(async()=>{if(_.current||!s)return;let t=g.current,r=!t;g.current=r,i(r),_.current=!0,d(!0),h(null),b.current+=1;try{let t=await fetch(`${e}/api/settings`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({codexAccountPickerEnabled:r})}),o=await a(t)??{};if(o.ok!==!0||typeof o.codexAccountPickerEnabled!=`boolean`)throw Error(`unconfirmed`);g.current=o.codexAccountPickerEnabled,i(o.codexAccountPickerEnabled),c(!0),p(!1),h(o.catalogRefreshPending===!0?{tone:`warn`,message:n(`codexAuth.catalogRefreshPending`)}:{tone:`ok`,message:n(`codexAuth.accountPickerUpdated`)})}catch{g.current=t,i(t),h({tone:`err`,message:n(`codexAuth.accountPickerUpdateFailed`)})}finally{_.current=!1,d(!1)}},[e,s,n]),C=f&&!s;return(0,y.jsxs)(`div`,{className:`card card-row codex-account-picker-card`,"aria-busy":l||!s&&!C||void 0,children:[(0,y.jsxs)(`div`,{className:`codex-account-picker-copy`,children:[(0,y.jsx)(`strong`,{children:n(`codexAuth.accountPickerTitle`)}),(0,y.jsx)(`div`,{className:`card-sub`,role:C?`status`:void 0,children:n(C?`codexAuth.accountPickerLoadFailed`:s?r?`codexAuth.accountPickerOnDesc`:`codexAuth.accountPickerOffDesc`:`common.loading`)}),s&&r&&(0,y.jsx)(`div`,{className:`card-sub faint`,children:n(`codexAuth.accountPickerCompatibility`)}),s&&f&&(0,y.jsx)(`div`,{className:`card-sub faint`,role:`status`,children:n(`codexAuth.accountPickerRefreshFailed`)})]}),(0,y.jsxs)(`div`,{className:`codex-account-picker-controls`,children:[f&&(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>{x()},disabled:l,children:n(`common.retry`)}),s&&(0,y.jsx)(`button`,{type:`button`,className:`toggle ${r?`on`:``}`,onClick:()=>{S()},disabled:l,"aria-pressed":r,"aria-label":n(`codexAuth.accountPickerTitle`),title:n(`codexAuth.accountPickerTitle`),children:(0,y.jsx)(`span`,{className:`toggle-knob`})})]}),m&&(0,y.jsx)(`div`,{className:`codex-account-picker-feedback is-${m.tone}`,role:m.tone===`err`?`alert`:`status`,"aria-atomic":`true`,children:m.message})]})}function C(e){if(!e||typeof e!=`object`)return`absent`;let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t)||!Object.hasOwn(t,`openai`))return`absent`;let n=t.openai;if(!n||typeof n!=`object`||Array.isArray(n))return`absent`;let r=n;return r.disabled===!0?`disabled`:r.codexAccountMode===`direct`?`direct`:r.codexAccountMode===void 0||r.codexAccountMode===`pool`?`pool`:`absent`}function w({state:e,busy:n,onEnable:r}){let a=t();return(0,y.jsxs)(`div`,{className:`panel openai-account-mode-banner`,style:{marginBottom:16},children:[(0,y.jsxs)(`div`,{className:`row`,children:[(0,y.jsx)(`strong`,{children:a(`codexAuth.accountModeTitle`)}),e===null?(0,y.jsx)(`span`,{className:`badge badge-accent openai-account-mode-banner__badge-slot openai-account-mode-banner__badge-slot--pending`,"aria-hidden":`true`,children:a(`codexAuth.accountModePool`)}):e===`pool`?(0,y.jsx)(`span`,{className:`badge badge-accent openai-account-mode-banner__badge-slot`,children:a(`codexAuth.accountModePool`)}):e===`direct`?(0,y.jsx)(`span`,{className:`badge badge-green openai-account-mode-banner__badge-slot`,children:a(`codexAuth.accountModeDirect`)}):null]}),e===null&&(0,y.jsx)(`p`,{className:`card-sub openai-account-mode-banner__desc openai-account-mode-banner__desc--pending`,"aria-hidden":`true`,children:`\xA0`}),e===`pool`&&(0,y.jsx)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:a(`codexAuth.accountModePoolDesc`)}),e===`direct`&&(0,y.jsxs)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:[a(`codexAuth.accountModeDirectDesc`),` `,(0,y.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>i(`providers`),children:a(`codexAuth.openProviders`)})]}),(e===`absent`||e===`disabled`)&&(0,y.jsxs)(`div`,{className:`row`,style:{alignItems:`center`,marginTop:8},children:[(0,y.jsx)(`p`,{className:`card-sub`,style:{flex:1,margin:0},children:a(`codexAuth.openaiUnavailableDesc`)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:n,onClick:r,children:a(n?`codexAuth.enablingOpenai`:`codexAuth.enableOpenai`)})]}),e===`invalid`&&(0,y.jsxs)(`p`,{className:`card-sub openai-account-mode-banner__desc`,children:[a(`codexAuth.openaiMissing`),` `,(0,y.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>i(`providers`),children:a(`codexAuth.openProviders`)})]})]})}function T(e){if(!e||typeof e!=`object`)return;let t=e.providers;if(!t||typeof t!=`object`||Array.isArray(t)||!Object.hasOwn(t,`openai`))return;let n=t.openai;if(!(!n||typeof n!=`object`||Array.isArray(n)))return n}function E({apiBase:e}){let n=t(),r=`ocx.codex-auth.config.v1:${e}`,i=l(r),[a,s]=(0,v.useState)(()=>i?.bannerState??null),[d,f]=(0,v.useState)(()=>i?.accountModeState??null),p=(0,v.useRef)(null),[b,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(``),k=(0,v.useCallback)(async()=>{let t=u(15e3);try{let n=await fetch(`${e}/api/config`,{signal:t.signal});if(!n.ok)throw Error(String(n.status));let i=await n.json(),a=g(T(i));if(a===`absent`||a===`disabled`||a===`invalid`){s(a);let e=a===`disabled`?`disabled`:`absent`;f(e),c(r,{bannerState:a,accountModeState:e});return}let o=C(i);s(o),f(o),c(r,{bannerState:o,accountModeState:o})}catch{}finally{t.clear()}},[e,r]);(0,v.useEffect)(()=>{p.current!==e&&(p.current=e,Promise.resolve().then(()=>{k()}));let t=o(()=>{k()},3e4);return()=>{t()}},[e,k]);let A=async()=>{E(!0),O(``);try{if(a!==`absent`&&a!==`disabled`)return;await m(e,a),await k()}catch(e){e instanceof _?O(n(e.i18nKey)):O(e instanceof Error?e.message:n(`prov.saveFailed`))}finally{E(!1)}};return(0,y.jsx)(y.Fragment,{children:(0,y.jsx)(h,{apiBase:e,accountModeState:d,banner:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(w,{state:a,busy:b,onEnable:()=>{A()}}),D&&(0,y.jsx)(`div`,{className:`notice notice-err`,role:`alert`,children:D})]}),advancedExtras:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(S,{apiBase:e}),(0,y.jsx)(x,{apiBase:e})]})})})}var D={"base-instructions":`codexSet.layer.base-instructions`,"model-switch":`codexSet.layer.model-switch`,personality:`codexSet.layer.personality`,"context-window-guidance":`codexSet.layer.context-window-guidance`,realtime:`codexSet.layer.realtime`,"agents-md":`codexSet.layer.agents-md`,permissions:`codexSet.layer.permissions`,collaboration:`codexSet.layer.collaboration`,environment:`codexSet.layer.environment`,"environments-instructions":`codexSet.layer.environments-instructions`,apps:`codexSet.layer.apps`,plugins:`codexSet.layer.plugins`,tools:`codexSet.layer.tools`,skills:`codexSet.layer.skills`,"multi-agent-mode":`codexSet.layer.multi-agent-mode`,"git-attribution":`codexSet.layer.git-attribution`},O={"base-instructions":`codexSet.about.base-instructions`,"model-switch":`codexSet.about.model-switch`,personality:`codexSet.about.personality`,"context-window-guidance":`codexSet.about.context-window-guidance`,realtime:`codexSet.about.realtime`,"agents-md":`codexSet.about.agents-md`,permissions:`codexSet.about.permissions`,collaboration:`codexSet.about.collaboration`,environment:`codexSet.about.environment`,"environments-instructions":`codexSet.about.environments-instructions`,apps:`codexSet.about.apps`,plugins:`codexSet.about.plugins`,tools:`codexSet.about.tools`,skills:`codexSet.about.skills`,"multi-agent-mode":`codexSet.about.multi-agent-mode`,"git-attribution":`codexSet.about.git-attribution`},k={"model-switch":`codexSet.condition.model-switch`,realtime:`codexSet.condition.realtime`,"agents-md":`codexSet.condition.agents-md`,plugins:`codexSet.condition.plugins`,"git-attribution":`codexSet.condition.git-attribution`},A={base:`codexSet.class.base`,"config-toggle":`codexSet.class.config-toggle`,"feature-gated":`codexSet.class.feature-gated`,"runtime-conditional":`codexSet.class.runtime-conditional`,"extension-unknown":`codexSet.class.extension-unknown`};function j({descriptor:e,toggle:n,bytes:r,transitionOnly:a=!1,busy:o,writesRefused:s,onToggle:c,onSelectBase:l,baseSelection:u,onOpen:d}){let f=t(),p=D[e.id],m=p?f(p):e.id,h=k[e.id],g=n?.defaultedUserValue??e.default??!0,_=u?.kind==="default";return(0,y.jsxs)(`li`,{className:`codex-set-prompt__row`,"data-layer-id":e.id,"data-layer-class":e.class,children:[(0,y.jsx)(`span`,{className:`codex-set-prompt__pos`,"aria-hidden":`true`,children:e.order===null?`·`:e.order+1}),(0,y.jsx)(`button`,{type:`button`,className:`link-btn codex-set-prompt__name`,onClick:()=>d(e.id),children:m}),e.key&&(0,y.jsx)(`code`,{className:`codex-set-prompt__key`,children:e.key}),r!==null&&r>0&&(0,y.jsx)(`span`,{className:`codex-set-prompt__bytes`,title:f(`codexSet.dialog.sourceBytes`,{bytes:r}),children:r>=1024?Math.round(r/1024)+` KB`:r+` B`}),e.class===`base`&&l?(0,y.jsx)(`button`,{type:`button`,role:`switch`,className:`toggle ${_?`on`:``}`,"aria-checked":_,"aria-label":m,disabled:o||s||u?.kind===`external`,onClick:()=>{l(!_)},children:(0,y.jsx)(`span`,{className:`toggle-knob`})}):e.class===`config-toggle`?(0,y.jsx)(`button`,{type:`button`,role:`switch`,className:`toggle ${g?`on`:``}`,"aria-checked":g,"aria-label":m,disabled:o||s,onClick:()=>{c(e.id,!g)},children:(0,y.jsx)(`span`,{className:`toggle-knob`})}):e.class===`feature-gated`?(0,y.jsxs)(`span`,{className:`codex-set-prompt__note`,children:[f(`codexSet.row.featureGated`),` `,(0,y.jsx)(`button`,{type:`button`,className:`link-btn`,onClick:()=>i(`integrations/codex`),children:f(`codexSet.row.openFeatures`)})]}):(0,y.jsx)(`span`,{className:`codex-set-prompt__note codex-set-prompt__note--locked`,children:f(a?`codexSet.row.onChange`:h||`codexSet.row.alwaysOn`)})]})}function M({descriptor:e,toggle:n,text:r,busy:i,onToggle:a,onClose:o}){let s=t(),c=(0,v.useRef)(null),l=`codex-set-layer-dialog-`+e.id;(0,v.useEffect)(()=>{let e=c.current,t=document.activeElement;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close(),t&&typeof t.focus==`function`&&t.focus()}},[]);let u=(0,v.useCallback)(e=>{e.preventDefault(),o()},[o]),d=A[e.class],f=D[e.id],p=O[e.id],m=k[e.id];return(0,y.jsxs)(`dialog`,{ref:c,className:`modal-overlay`,"aria-labelledby":l,onCancel:u,children:[(0,y.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":s(`common.close`),tabIndex:-1,onClick:o}),(0,y.jsxs)(`div`,{className:`modal-card codex-set-layer-dialog`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,y.jsxs)(`div`,{className:`modal-head`,children:[(0,y.jsx)(`h3`,{id:l,children:f?s(f):e.id}),e.class===`config-toggle`&&n&&(0,y.jsx)(`button`,{type:`button`,role:`switch`,className:`toggle ${n.defaultedUserValue?`on`:``}`,"aria-checked":n.defaultedUserValue,"aria-label":f?s(f):e.id,disabled:i,onClick:()=>{a(e.id,!n.defaultedUserValue)},children:(0,y.jsx)(`span`,{className:`toggle-knob`})}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:o,children:s(`common.close`)})]}),(0,y.jsx)(`p`,{className:`muted small`,children:s(p||`codexSet.dialog.unknownLayer`)}),(0,y.jsxs)(`div`,{className:`codex-set-layer-dialog__line`,children:[(0,y.jsx)(`span`,{className:`muted text-label`,children:s(`codexSet.dialog.class`)}),(0,y.jsx)(`span`,{children:s(d)})]}),e.key&&(0,y.jsxs)(`div`,{className:`codex-set-layer-dialog__line`,children:[(0,y.jsx)(`span`,{className:`muted text-label`,children:s(`codexSet.dialog.key`)}),(0,y.jsx)(`code`,{className:`api-code`,children:e.key}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>{navigator.clipboard?.writeText(e.key??``)},children:s(`codexSet.dialog.copyKey`)})]}),e.class===`config-toggle`&&n&&(0,y.jsxs)(`div`,{className:`codex-set-layer-dialog__line`,children:[(0,y.jsx)(`span`,{className:`muted text-label`,children:s(`codexSet.dialog.fileValue`)}),(0,y.jsx)(`span`,{children:n.userFileValue===null?s(`codexSet.dialog.absentDefault`,{value:String(n.default)}):s(`codexSet.dialog.setValue`,{value:String(n.userFileValue),fallback:String(n.default)})})]}),e.class===`runtime-conditional`&&m&&(0,y.jsx)(`p`,{className:`muted small`,children:s(m)}),r?.reason===`ok`&&r.text?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`codex-set-layer-dialog__line`,children:[(0,y.jsx)(`span`,{className:`muted text-label`,children:s(`codexSet.dialog.sourceText`)}),(0,y.jsx)(`span`,{className:`muted small`,children:s(`codexSet.dialog.sourceBytes`,{bytes:r.bytes})})]}),(0,y.jsx)(`pre`,{className:`api-code codex-set-layer-dialog__text`,children:r.text})]}):(0,y.jsx)(`p`,{className:`muted small codex-set-layer-dialog__no-text`,children:r?.reason===`empty-source`?s(`codexSet.dialog.emptySource`,{path:r.sourcePath??``}):r?.reason===`not-rendered`?s(`codexSet.dialog.notRendered`):r?.reason===`not-exposed`?s(`codexSet.dialog.notExposed`):s(`codexSet.dialog.textUnavailable`)})]})]})}function N({layer:e,index:n,total:r,busy:i,onToggle:a,onEdit:o,onDelete:s,onMove:c}){let l=t();return(0,y.jsxs)(`li`,{className:`codex-set-prompt__row codex-set-custom__row`,"data-custom-id":e.id,onKeyDown:t=>{!t.altKey||i||(t.key===`ArrowUp`&&n>0?(t.preventDefault(),c(e.id,-1)):t.key===`ArrowDown`&&n<r-1&&(t.preventDefault(),c(e.id,1)))},children:[(0,y.jsx)(`span`,{className:`codex-set-prompt__pos`,"aria-hidden":`true`,children:n+1}),(0,y.jsx)(`button`,{type:`button`,className:`link-btn codex-set-prompt__name`,onClick:()=>o(e.id),children:e.title}),(0,y.jsxs)(`span`,{className:`codex-set-custom__reorder`,children:[(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":l(`codexSet.custom.moveUp`,{title:e.title}),disabled:n===0||i,onClick:()=>c(e.id,-1),children:`↑`}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":l(`codexSet.custom.moveDown`,{title:e.title}),disabled:n===r-1||i,onClick:()=>c(e.id,1),children:`↓`})]}),(0,y.jsx)(`button`,{type:`button`,role:`switch`,className:`toggle ${e.enabled?`on`:``}`,"aria-checked":e.enabled,"aria-label":e.title,disabled:i,onClick:()=>a(e.id,!e.enabled),children:(0,y.jsx)(`span`,{className:`toggle-knob`})}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm codex-set-custom__delete`,"aria-label":l(`codexSet.custom.delete`,{title:e.title}),disabled:i,onClick:()=>s(e.id),children:`×`})]})}var P=8192,F=[{rule:`identity`,level:`warn`,messageKey:`codexSet.lint.identity`,pattern:/you\s+are\s+(claude|grok|gemini|gpt-|chatgpt)/gi},{rule:`foreign-tool`,level:`warn`,messageKey:`codexSet.lint.foreignTool`,pattern:/\b(Read|Edit|Write|Bash|Glob|Grep)\s+tool\b/g},{rule:`placeholder`,level:`warn`,messageKey:`codexSet.lint.placeholder`,pattern:/\$\{\{[\s\S]*?\}\}/g},{rule:`apply-patch`,level:`warn`,messageKey:`codexSet.lint.applyPatch`,pattern:/apply_patch\s+(?:is|must|should|means|works)/gi},{rule:`approval-vocab`,level:`warn`,messageKey:`codexSet.lint.approvalVocab`,pattern:/\b(always-approve|ask mode|acceptEdits)\b/gi},{rule:`environment`,level:`warn`,messageKey:`codexSet.lint.environment`,pattern:/\b(your (?:cwd|working directory) is|today's date is|you have no network access|you are running on (?:macos|linux|windows))/gi}];function I(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}function L(e){let t=[];for(let n of F){let r=new RegExp(n.pattern.source,n.pattern.flags);for(let i=r.exec(e);i!==null;i=r.exec(e))t.push({level:n.level,rule:n.rule,messageKey:n.messageKey,span:[i.index,i.index+i[0].length]}),i[0].length===0&&(r.lastIndex+=1)}return I(e)>P&&t.push({level:`info`,rule:`size`,messageKey:`codexSet.lint.size`}),t.sort((e,t)=>(e.span?.[0]??1/0)-(t.span?.[0]??1/0))}var R=65536;function z(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}function B(e){return e.replace(/\r\n/g,`
3
+ `).replace(/\r/g,`
4
+ `).replace(/\t/g,` `)}function V(e){let t=0;for(let n of e){let e=n.codePointAt(0);if(n!==`
5
+ `&&(e<32||e===127)||e>=55296&&e<=57343)return{position:t};t+=1}return null}function H(e,t){let n=e.title;if(n.trim().length===0)return{kind:`title-empty`};if(n.length>80)return{kind:`title-too-long`,length:n.length};if(/[\r\n]/.test(n))return{kind:`title-multiline`};let r=B(e.body),i=z(r);if(i>65536)return{kind:`body-too-large`,bytes:i};let a=V(r);if(a)return{kind:`invalid-character`,position:a.position};let o=z([...t.filter(t=>t.enabled&&t.id!==e.id).map(e=>e.body),...e.enabled?[r]:[]].join(`
6
+
7
+ `));return o>131072?{kind:`composed-too-large`,bytes:o}:null}function U(e){let t=new Set(e.map(e=>e.id));for(;;){let e=``;for(let t=0;t<6;t+=1)e+=`abcdefghijklmnopqrstuvwxyz0123456789`[Math.floor(Math.random()*36)];if(!t.has(e))return e}}function W(e,t,n){let r=[...e],i=r.findIndex(e=>e.id===t);if(i===-1)return r;let a=i+n;if(a<0||a>=r.length)return r;let[o]=r.splice(i,1);return r.splice(a,0,o),r}function G({layer:e,seed:n,others:r,busy:i,navigation:a,onSave:o,onClose:s}){let c=t(),l=(0,v.useRef)(null),[u,d]=(0,v.useState)(e?.title??n?.title??``),[f,p]=(0,v.useState)(e?.body??n?.body??``),m=(0,v.useRef)(new Map),h=e?.id??null,g=(0,v.useRef)(h),_=(0,v.useRef)({title:u,body:f});(0,v.useEffect)(()=>{_.current={title:u,body:f}},[u,f]),(0,v.useEffect)(()=>{if(g.current===h)return;g.current!==null&&m.current.set(g.current,_.current),g.current=h;let t=h===null?void 0:m.current.get(h);d(t?.title??e?.title??``),p(t?.body??e?.body??``)},[h,e]);let[b,x]=(0,v.useState)(!1),S=`codex-set-custom-dialog`,C=e?.title??n?.title??``,w=e?.body??n?.body??``,T=u!==C||f!==w;(0,v.useEffect)(()=>{let e=l.current,t=document.activeElement;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close(),t&&typeof t.focus==`function`&&t.focus()}},[]);let E=(0,v.useCallback)(()=>{if(T){x(!0);return}s()},[T,s]),D=(0,v.useCallback)(e=>{e.preventDefault(),E()},[E]),O={id:e?.id??null,title:u,body:f,enabled:e?.enabled??!0},k=H(O,r),A=B(f),j=A!==f,M=(0,v.useMemo)(()=>L(A),[A]),N=z(A),P=k?k.kind===`title-empty`?c(`codexSet.custom.titleRequired`):k.kind===`title-too-long`?c(`codexSet.custom.titleTooLong`,{count:k.length,max:80}):k.kind===`title-multiline`?c(`codexSet.custom.titleMultiline`):k.kind===`body-too-large`?c(`codexSet.custom.bodyTooLarge`,{bytes:k.bytes,max:R}):k.kind===`composed-too-large`?c(`codexSet.custom.composedTooLarge`,{bytes:k.bytes}):c(`codexSet.custom.invalidCharacter`,{position:k.position}):null;return(0,y.jsxs)(`dialog`,{ref:l,className:`modal-overlay`,"aria-labelledby":S,onCancel:D,children:[(0,y.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":c(`common.close`),tabIndex:-1,onClick:E}),(0,y.jsxs)(`div`,{className:`modal-card codex-set-custom-dialog`,onClick:e=>e.stopPropagation(),role:`document`,children:[(0,y.jsxs)(`div`,{className:`modal-head`,children:[(0,y.jsx)(`h3`,{id:S,children:c(e?`codexSet.custom.editTitle`:`codexSet.custom.newTitle`)}),a&&(0,y.jsxs)(`span`,{className:`codex-set-custom-dialog__nav`,children:[(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":c(`codexSet.custom.prevLayer`),disabled:a.position<=1||i,onClick:a.onPrev,children:`←`}),(0,y.jsx)(`span`,{className:`codex-set-custom-dialog__nav-pos`,children:c(`codexSet.custom.navPosition`,{position:a.position,total:a.total})}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":c(`codexSet.custom.nextLayer`),disabled:a.position>=a.total||i,onClick:a.onNext,children:`→`})]})]}),(0,y.jsxs)(`label`,{className:`field`,children:[(0,y.jsx)(`span`,{className:`muted text-label`,children:c(`codexSet.custom.titleLabel`)}),(0,y.jsx)(`input`,{type:`text`,value:u,maxLength:100,onChange:e=>d(e.target.value)})]}),(0,y.jsxs)(`label`,{className:`field`,children:[(0,y.jsx)(`span`,{className:`muted text-label`,children:c(`codexSet.custom.bodyLabel`)}),(0,y.jsx)(`textarea`,{rows:10,value:f,onChange:e=>p(e.target.value)})]}),(0,y.jsx)(`p`,{className:`muted small`,children:c(`codexSet.custom.bodySize`,{bytes:N,max:R})}),j&&(0,y.jsx)(`p`,{className:`muted small codex-set-custom-dialog__normalized`,children:c(`codexSet.custom.normalized`)}),P&&(0,y.jsx)(`div`,{className:`notice notice-err`,role:`alert`,children:P}),M.length>0&&(0,y.jsx)(`ul`,{className:`codex-set-custom-dialog__lint`,children:M.map((e,t)=>(0,y.jsxs)(`li`,{"data-lint-rule":e.rule,"data-lint-level":e.level,children:[c(e.messageKey),e.span&&(0,y.jsx)(`code`,{className:`codex-set-custom-dialog__span`,children:A.slice(e.span[0],e.span[1])})]},e.rule+`:`+t))}),b?(0,y.jsxs)(`div`,{className:`modal-actions codex-set-custom-dialog__discard`,role:`alertdialog`,"aria-labelledby":S+`-discard`,children:[(0,y.jsx)(`span`,{id:S+`-discard`,className:`muted small`,children:c(`codexSet.custom.discardPrompt`)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>x(!1),children:c(`codexSet.custom.keepEditing`)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:s,children:c(`common.discard`)})]}):(0,y.jsxs)(`div`,{className:`modal-actions`,children:[(0,y.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:k!==null||i,onClick:()=>o({...O,body:A}),children:c(`common.save`)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:E,children:c(`common.cancel`)})]})]})]})}var K=Object.freeze([{id:`concise`,nameKey:`codexSet.preset.concise.name`,descriptionKey:`codexSet.preset.concise.description`,provenanceKey:`codexSet.preset.concise.provenance`,body:[`Answer directly. Skip preamble, restatement of the question, and summaries of the work about to be done.`,`Prefer a short paragraph over a list, and a list over a table, unless the structure carries real meaning.`,`When the answer is a single fact, give the fact and stop.`].join(`
8
+ `)},{id:`plan-first`,nameKey:`codexSet.preset.planFirst.name`,descriptionKey:`codexSet.preset.planFirst.description`,provenanceKey:`codexSet.preset.planFirst.provenance`,body:[`Before changing anything non-trivial, state the plan in two or three sentences: what will change, where, and how it will be verified.`,`If the plan turns out to be wrong mid-way, say so and revise it rather than continuing quietly.`].join(`
9
+ `)},{id:`explain-why`,nameKey:`codexSet.preset.explainWhy.name`,descriptionKey:`codexSet.preset.explainWhy.description`,provenanceKey:`codexSet.preset.explainWhy.provenance`,body:[`When a choice had alternatives, name the alternative and why it lost.`,`Explain reasoning where it changes what the reader should do, not as a narration of every step.`,`State uncertainty plainly instead of presenting a guess as a conclusion.`].join(`
10
+ `)},{id:`test-first`,nameKey:`codexSet.preset.testFirst.name`,descriptionKey:`codexSet.preset.testFirst.description`,provenanceKey:`codexSet.preset.testFirst.provenance`,body:[`For a behavior change, write the failing test first and show that it fails for the expected reason.`,`A test that passes before the change is not evidence; say so rather than counting it.`].join(`
11
+ `)},{id:`korean`,nameKey:`codexSet.preset.korean.name`,descriptionKey:`codexSet.preset.korean.description`,provenanceKey:`codexSet.preset.korean.provenance`,body:[`Reply in Korean regardless of the language of the request, unless explicitly asked for another language.`,`Keep code, identifiers, file paths, and command output unchanged.`,`Write plain Korean: no translationese, one consistent register throughout.`].join(`
12
+ `)}]);function ee({onBlank:e,onPreset:n,disabled:r,presets:i=K}){let a=t(),[o,s]=(0,v.useState)(!1),c=(0,v.useRef)(null),l=o&&!r;(0,v.useEffect)(()=>{if(!l)return;let e=e=>{c.current?.contains(e.target)||s(!1)},t=e=>{e.key===`Escape`&&s(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]);let u=e=>{s(!1),e()};return i.length===0?(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm codex-set-custom__add`,disabled:r,onClick:e,children:a(`codexSet.custom.add`)}):(0,y.jsxs)(`div`,{className:`codex-set-preset`,ref:c,children:[(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm codex-set-custom__add`,"aria-expanded":l,disabled:r,onClick:()=>s(e=>!e),children:a(`codexSet.custom.add`)}),l&&(0,y.jsxs)(`div`,{className:`codex-set-preset__menu`,children:[(0,y.jsx)(`button`,{type:`button`,className:`codex-set-preset__item`,onClick:()=>u(e),children:(0,y.jsx)(`span`,{className:`codex-set-preset__name`,children:a(`codexSet.preset.blank`)})}),i.map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`codex-set-preset__item`,"data-preset-id":e.id,onClick:()=>u(()=>n(e.body,a(e.nameKey))),children:[(0,y.jsx)(`span`,{className:`codex-set-preset__name`,children:a(e.nameKey)}),(0,y.jsx)(`span`,{className:`codex-set-preset__desc`,children:a(e.descriptionKey)}),(0,y.jsx)(`span`,{className:`codex-set-preset__provenance`,children:a(e.provenanceKey)}),(0,y.jsx)(`span`,{className:`codex-set-preset__preview`,children:e.body})]},e.id))]})]})}var q=48;function te({variants:e,selection:n,maxVariants:r,busy:i,onSelect:a,onSave:o,onDelete:s,onClose:c}){let l=t(),u=(0,v.useRef)(null),d=[{kind:`default`},...e.map(e=>({kind:`variant`,variant:e})),...e.length<r?[{kind:`new`}]:[]],f=n.kind===`variant`?Math.max(0,d.findIndex(e=>e.variant?.id===n.id)):0,[p,m]=(0,v.useState)(f),h=d[Math.min(p,d.length-1)],[g,_]=(0,v.useState)(h.variant?.title??``),[b,x]=(0,v.useState)(h.variant?.body??``),[S,C]=(0,v.useState)(h.variant?.id??null);(h.variant?.id??null)!==S&&(C(h.variant?.id??null),_(h.variant?.title??``),x(h.variant?.body??``));let w=(0,v.useCallback)(e=>{m(t=>{let n=t+e;return n<0?d.length-1:n>=d.length?0:n})},[d.length]);(0,v.useEffect)(()=>{let e=u.current;e&&!e.open&&e.showModal()},[]);let T=(0,v.useRef)(null),E=e=>{T.current={x:e.clientX,y:e.clientY}},D=e=>{let t=T.current;if(T.current=null,!t||i)return;let n=e.clientX-t.x,r=e.clientY-t.y;Math.abs(n)<q||Math.abs(n)<=Math.abs(r)||w(n<0?1:-1)},O=e=>{if(i)return;let t=e.target.tagName;t!==`TEXTAREA`&&t!==`INPUT`&&(e.key===`ArrowLeft`&&(e.preventDefault(),w(-1)),e.key===`ArrowRight`&&(e.preventDefault(),w(1)))},k=h.kind==="default"?n.kind==="default":h.kind===`variant`&&n.kind===`variant`&&n.id===h.variant.id,A=n.kind===`external`;return(0,y.jsx)(`dialog`,{ref:u,className:`modal-overlay codex-set-base-dialog`,"aria-label":l(`codexSet.base.title`),onClose:c,onKeyDown:O,onPointerDown:E,onPointerUp:D,children:(0,y.jsxs)(`div`,{className:`modal-card`,children:[(0,y.jsxs)(`div`,{className:`row`,children:[(0,y.jsx)(`strong`,{children:l(`codexSet.base.title`)}),(0,y.jsxs)(`span`,{className:`codex-set-base-dialog__nav`,children:[(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":l(`codexSet.base.prev`),disabled:i||d.length<2,onClick:()=>w(-1),children:`←`}),(0,y.jsx)(`span`,{className:`codex-set-base-dialog__pos`,"data-slot-kind":h.kind,children:l(`codexSet.base.position`,{position:p+1,total:d.length})}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,"aria-label":l(`codexSet.base.next`),disabled:i||d.length<2,onClick:()=>w(1),children:`→`})]})]}),(0,y.jsx)(`p`,{className:`card-sub`,children:l(`codexSet.base.swipeHint`)}),d.length>1&&(0,y.jsx)(`div`,{className:`codex-set-base-dialog__dots`,"aria-hidden":`true`,children:d.map((e,t)=>(0,y.jsx)(`span`,{className:`codex-set-base-dialog__dot${t===p?` active`:``}`},t))}),A&&(0,y.jsx)(`div`,{className:`notice notice-err`,role:`alert`,children:l(`codexSet.base.externalBlocked`,{path:n.path})}),h.kind==="default"?(0,y.jsxs)(`div`,{className:`codex-set-base-dialog__default`,children:[(0,y.jsx)(`strong`,{children:l(`codexSet.base.defaultTitle`)}),(0,y.jsx)(`p`,{className:`muted small`,children:l(`codexSet.base.defaultBody`)})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`field`,children:[(0,y.jsx)(`span`,{children:l(`codexSet.base.variantTitle`)}),(0,y.jsx)(`input`,{type:`text`,value:g,disabled:i||A,onChange:e=>_(e.target.value)})]}),(0,y.jsxs)(`label`,{className:`field`,children:[(0,y.jsx)(`span`,{children:l(`codexSet.base.variantBody`)}),(0,y.jsx)(`textarea`,{rows:12,value:b,disabled:i||A,onChange:e=>x(e.target.value)})]}),(0,y.jsx)(`p`,{className:`muted small`,children:l(`codexSet.base.replacesWarning`)})]}),(0,y.jsxs)(`div`,{className:`modal-actions`,children:[h.kind!=="default"&&(0,y.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:i||A||b.trim().length===0,onClick:()=>o({id:h.variant?.id??null,title:g,body:b}),children:l(`common.save`)}),!k&&h.kind!==`new`&&(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:i||A,onClick:()=>a(h.kind==="default"?{kind:`default`}:{kind:`variant`,id:h.variant.id}),children:l(`codexSet.base.use`)}),k&&(0,y.jsx)(`span`,{className:`pill`,children:l(`codexSet.base.inUse`)}),h.kind===`variant`&&(0,y.jsx)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,disabled:i||A,onClick:()=>s(h.variant.id),children:l(`common.delete`)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:c,children:l(`common.close`)})]})]})})}function ne(e){return`codex-prompt:`+e}var re={"journal-present":`codexSet.drift.journalPresent`,"projection-stale":`codexSet.drift.projectionStale`,"store-missing":`codexSet.drift.storeMissing`,"owned-malformed":`codexSet.drift.ownedMalformed`};function J({apiBase:e}){let n=t(),r=ne(e),[i,a]=(0,v.useState)(``),[o,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),A=(0,v.useCallback)(()=>{k(null)},[]),P=(0,v.useCallback)(async t=>{let n=await fetch(e+`/api/codex-prompt`,{signal:t});if(!n.ok)throw Error(String(n.status));return await n.json()},[e]),F=d(r,[e],P,{isEmpty:e=>e.inventory.length===0}),I=F.data,L=F.state,R=async(t,i)=>{if(I){c(t),a(``);try{let o=await fetch(e+`/api/codex-prompt/toggle`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t,enabled:i,revision:I.revision})}),c=await o.json();if(!o.ok||!c.ok||!c.snapshot){if(c.code===`stale_revision`){F.refresh(),a(n(`codexSet.prompt.staleRevision`));return}a(c.message??n(`codexSet.prompt.writeFailed`)),F.refresh();return}s(r,c.snapshot),A(),k(null)}catch{a(n(`codexSet.prompt.writeFailed`)),F.refresh()}finally{c(null)}}},z=async(t,i)=>{if(!(!I||o!==null)){c(`base`),a(``);try{let o=await fetch(e+t,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({...i,revision:I.revision})}),c=await o.json();if(!o.ok||!c.ok||!c.snapshot){if(c.code===`stale_revision`){F.refresh(),a(n(`codexSet.prompt.staleRevision`));return}a(c.message??n(`codexSet.prompt.writeFailed`)),F.refresh();return}s(r,c.snapshot),A(),k(null)}catch{a(n(`codexSet.prompt.writeFailed`)),F.refresh()}finally{c(null)}}},B=async(t,i)=>{if(!I||o!==null)return!1;c(i),a(``);let l=I.custom;try{let i=await fetch(e+`/api/codex-prompt/custom`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({layers:t,revision:I.revision})}),o=await i.json();return!i.ok||!o.ok||!o.snapshot?o.code===`stale_revision`?(F.refresh(),a(n(`codexSet.prompt.staleRevision`)),!1):(a(o.message??n(`codexSet.prompt.writeFailed`)),s(r,{...I,custom:l}),F.refresh(),!1):(s(r,o.snapshot),A(),!0)}catch{return a(n(`codexSet.prompt.writeFailed`)),F.refresh(),!1}finally{c(null)}},V=async e=>{if(!I)return;let t=I.custom,n=e.id===null?[...t,{id:U(t),title:e.title,body:e.body,enabled:!0}]:t.map(t=>t.id===e.id?{...t,title:e.title,body:e.body}:t);await B(n,e.id??`new`)&&h(null)},H=async t=>{if(I){c(`adopt`),a(``);try{let i=await fetch(e+`/api/codex-prompt/adopt`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t?{confirm:!0,revision:I.revision}:{confirm:!1})}),o=await i.json();if(!i.ok||!o.ok){a(o.message??n(`codexSet.custom.adoptRefused`)),x(null),C(o.code===`adopt_unsupported_form`?{path:o.path,line:o.line,rawLine:o.rawLine}:null);return}if(o.snapshot){s(r,o.snapshot),A(),x(null);return}x(o.preview??null)}catch{a(n(`codexSet.prompt.writeFailed`))}finally{c(null)}}},K=async t=>{if(!(!I||I.drift===null)){T(!0),a(``);try{let i=await fetch(e+`/api/codex-prompt/repair`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t?{confirm:!0,revision:I.revision}:{confirm:!1})}),o=await i.json();if(!i.ok||!o.ok){a(o.message??n(`codexSet.prompt.repairFailed`));return}o.snapshot?s(r,o.snapshot):F.refresh(),A()}catch{a(n(`codexSet.prompt.repairFailed`))}finally{T(!1)}}},q=[...I?.inventory??[]].filter(e=>e.class!==`extension-unknown`).sort((e,t)=>(e.order??2**53-1)-(t.order??2**53-1)),J=new Set([`realtime`,`model-switch`]),Y=q.filter(e=>!J.has(e.id)),X=q.filter(e=>J.has(e.id)),Z=q.find(e=>e.id===l)??null,Q=m===null||m===`new`?-1:I?.custom.findIndex(e=>e.id===m)??-1,ie=Q>=0?I.custom[Q]:null,$=m!==null&&m!==`new`&&I!==void 0&&Q<0;return(0,v.useEffect)(()=>{if(O!==null)return;let t=!1;return(async()=>{try{let n=await fetch(e+`/api/codex-prompt/text`);if(!n.ok){t||k({ok:!1});return}let r=await n.json();t||k(r)}catch{t||k({ok:!1})}})(),()=>{t=!0}},[O,e]),(0,y.jsxs)(`div`,{className:`panel codex-set-prompt`,children:[(0,y.jsx)(`div`,{className:`row`,children:(0,y.jsx)(`strong`,{children:n(`codexSet.prompt.title`)})}),(0,y.jsx)(`p`,{className:`card-sub`,children:n(`codexSet.prompt.timing`)}),L.refreshing&&(0,y.jsx)(f,{live:!L.showError,children:n(`common.loading`)}),L.showSkeleton&&(0,y.jsx)(p,{label:n(`common.loading`),rows:5}),I&&!I.readable&&(0,y.jsx)(`div`,{className:`notice notice-err`,role:`alert`,children:n(`codexSet.prompt.unreadable`)}),L.showError&&(0,y.jsx)(`div`,{className:`notice notice-err`,role:`alert`,children:n(`codexSet.prompt.loadFailed`)}),(i||$)&&(0,y.jsx)(`div`,{className:`notice notice-err`,role:`alert`,children:$?n(`codexSet.custom.layerGone`):i}),I?.drift&&(0,y.jsxs)(`div`,{className:`notice codex-set-prompt__drift`,role:`alert`,"data-drift":I.drift,children:[(0,y.jsx)(`span`,{children:n(re[I.drift])}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:w,onClick:()=>{K(!0)},children:n(`codexSet.prompt.repair`)})]}),(0,y.jsx)(`ul`,{className:`codex-set-prompt__rows`,children:Y.map(e=>(0,y.jsx)(j,{descriptor:e,toggle:I?.toggles.find(t=>t.id===e.id),bytes:O?.layers?.[e.id]?.bytes??null,busy:o===e.id,writesRefused:I?.readable===!1,onToggle:(e,t)=>{R(e,t)},onSelectBase:e.class===`base`&&I?(t=>{if(t){z(`/api/codex-prompt/base/select`,{kind:`default`});return}let n=I.baseVariants[0];if(!n){u(e.id);return}z(`/api/codex-prompt/base/select`,{kind:`variant`,id:n.id})}):void 0,baseSelection:I?.baseSelection,onOpen:u},e.id))}),X.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`row codex-set-prompt__group`,children:(0,y.jsx)(`strong`,{children:n(`codexSet.group.transition`)})}),(0,y.jsx)(`p`,{className:`muted small`,children:n(`codexSet.group.transitionDesc`)}),(0,y.jsx)(`ul`,{className:`codex-set-prompt__rows`,children:X.map(e=>(0,y.jsx)(j,{descriptor:e,toggle:I?.toggles.find(t=>t.id===e.id),bytes:O?.layers?.[e.id]?.bytes??null,transitionOnly:!0,busy:o===e.id,writesRefused:I?.readable===!1,onToggle:(e,t)=>{R(e,t)},onOpen:u},e.id))})]}),I&&!I.extensionLayersEnumerable&&(0,y.jsx)(`p`,{className:`muted small codex-set-prompt__extensions`,children:n(`codexSet.prompt.extensionsUnknown`)}),Z&&(Z.class===`base`&&I?(0,y.jsx)(te,{variants:I.baseVariants,selection:I.baseSelection,maxVariants:I.maxBaseVariants,busy:o!==null||!I.readable,onSelect:e=>{z(`/api/codex-prompt/base/select`,e)},onSave:e=>{z(`/api/codex-prompt/base`,e)},onDelete:e=>{z(`/api/codex-prompt/base`,{id:e,delete:!0})},onClose:()=>u(null)}):(0,y.jsx)(M,{descriptor:Z,toggle:I?.toggles.find(e=>e.id===Z.id),text:O?.layers?.[Z.id],busy:o!==null,onToggle:(e,t)=>{R(e,t)},onClose:()=>u(null)})),I&&(0,y.jsxs)(`section`,{className:`codex-set-custom`,children:[(0,y.jsxs)(`div`,{className:`row`,children:[(0,y.jsx)(`strong`,{children:n(`codexSet.custom.heading`)}),I.developerInstructionsState===`external`?null:(0,y.jsx)(ee,{disabled:I.custom.length>=32||o!==null||!I.readable,onBlank:()=>{D(null),h(`new`)},onPreset:(e,t)=>{D({body:e,title:t}),h(`new`)}})]}),I.custom.length>=32&&(0,y.jsx)(`p`,{className:`muted small`,children:n(`codexSet.custom.limitReached`,{max:32})}),I.developerInstructionsState===`external`&&I.modelInstructionsFile===null&&(0,y.jsxs)(`div`,{className:`codex-set-custom__adopt`,children:[(0,y.jsx)(`p`,{className:`muted small`,children:n(`codexSet.custom.notOwned`)}),S&&(0,y.jsx)(`p`,{className:`muted small codex-set-custom__adopt-refusal`,children:n(`codexSet.custom.adoptUnsupported`,{path:S.path??``,line:S.line??0})}),b?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`pre`,{className:`api-code codex-set-custom__adopt-preview`,children:b.decodedBody}),(0,y.jsxs)(`div`,{className:`modal-actions`,children:[(0,y.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,disabled:o!==null,onClick:()=>{H(!0)},children:n(`codexSet.custom.adoptConfirm`)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>x(null),children:n(`common.cancel`)})]})]}):(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,disabled:o!==null,onClick:()=>{H(!1)},children:n(`codexSet.custom.adopt`)})]}),I.modelInstructionsFile!==null&&(0,y.jsx)(`p`,{className:`muted small codex-set-custom__replaced`,children:n(`codexSet.custom.baseReplaced`,{path:I.modelInstructionsFile})}),(0,y.jsx)(`ul`,{className:`codex-set-prompt__rows`,children:I.custom.map((e,t)=>(0,y.jsx)(N,{layer:e,index:t,total:I.custom.length,busy:o!==null||!I.readable,onToggle:(e,t)=>{B(I.custom.map(n=>n.id===e?{...n,enabled:t}:n),e)},onEdit:h,onDelete:_,onMove:(e,t)=>{B(W(I.custom,e,t),e)}},e.id))}),g&&(0,y.jsxs)(`div`,{className:`notice codex-set-custom__confirm`,role:`alertdialog`,"aria-labelledby":`codex-set-delete-confirm`,children:[(0,y.jsx)(`span`,{id:`codex-set-delete-confirm`,children:n(`codexSet.custom.deleteConfirmNamed`,{title:I.custom.find(e=>e.id===g)?.title??``})}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-danger btn-sm`,onClick:()=>{let e=g;_(null),B(I.custom.filter(t=>t.id!==e),e)},children:n(`common.delete`)}),(0,y.jsx)(`button`,{type:`button`,className:`btn btn-sm`,onClick:()=>_(null),children:n(`common.cancel`)})]})]}),m&&I&&!$&&(0,y.jsx)(G,{layer:m===`new`?null:ie,seed:m===`new`?E:null,others:I.custom,busy:o!==null,navigation:Q>=0&&I.custom.length>1?{position:Q+1,total:I.custom.length,onPrev:()=>{Q>0&&h(I.custom[Q-1].id)},onNext:()=>{Q<I.custom.length-1&&h(I.custom[Q+1].id)}}:void 0,onSave:V,onClose:()=>{h(null),D(null)}})]})}function Y(){return window.location.hash.replace(/^#\/?/,``)===`codex-set/prompt`?`prompt`:`multiauth`}function X(e){window.location.hash=e===`prompt`?`codex-set/prompt`:`codex-set`}function Z(e){e.key===`ArrowLeft`||e.key===`Home`?(e.preventDefault(),X(`multiauth`),document.getElementById(`codex-set-tab-multiauth`)?.focus()):(e.key===`ArrowRight`||e.key===`End`)&&(e.preventDefault(),X(`prompt`),document.getElementById(`codex-set-tab-prompt`)?.focus())}function Q({apiBase:e}){let n=t(),[r,i]=(0,v.useState)(Y),[a,o]=(0,v.useState)(()=>Y()===`prompt`),[s,c]=(0,v.useState)(()=>Y()===`multiauth`);(0,v.useEffect)(()=>{let e=()=>i(Y());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let l=a||r===`prompt`,u=s||r===`multiauth`;return l!==a&&o(!0),u!==s&&c(!0),(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":n(`nav.codexSet`),children:[(0,y.jsx)(`button`,{type:`button`,role:`tab`,id:`codex-set-tab-multiauth`,"aria-selected":r===`multiauth`,"aria-controls":`codex-set-panel-multiauth`,tabIndex:r===`multiauth`?0:-1,className:`page-tab${r===`multiauth`?` page-tab--active`:``}`,onClick:()=>X(`multiauth`),onKeyDown:Z,children:n(`codexSet.tab.multiauth`)}),(0,y.jsx)(`button`,{type:`button`,role:`tab`,id:`codex-set-tab-prompt`,"aria-selected":r===`prompt`,"aria-controls":`codex-set-panel-prompt`,tabIndex:r===`prompt`?0:-1,className:`page-tab${r===`prompt`?` page-tab--active`:``}`,onClick:()=>X(`prompt`),onKeyDown:Z,children:n(`codexSet.tab.prompt`)})]}),l&&(0,y.jsx)(`div`,{role:`tabpanel`,id:`codex-set-panel-prompt`,"aria-labelledby":`codex-set-tab-prompt`,hidden:r!==`prompt`,children:(0,y.jsx)(J,{apiBase:e})}),u&&(0,y.jsx)(`div`,{role:`tabpanel`,id:`codex-set-panel-multiauth`,"aria-labelledby":`codex-set-tab-multiauth`,hidden:r!==`multiauth`,children:(0,y.jsx)(E,{apiBase:e})})]})}export{Q as default};
@@ -0,0 +1 @@
1
+ import{_ as e,c as t,h as n,m as r}from"./shared-p0R307IX.js";import{F as i,L as a}from"./index-CEcmjvjC.js";import{t as o}from"./data-surface-Cq2fDI2w.js";import{f as s,g as c,h as l,n as u,p as d,t as f}from"./RestoreDialog-BnPA60nS.js";var p=e(n(),1),m=r(),h={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`,dsh:`integrations.semantics.dsh`,mcode:`integrations.semantics.mcode`,zcode:`integrations.semantics.zcode`,prime:`integrations.semantics.prime`},g={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`,dsh:`integrations.tab.dsh`,mcode:`integrations.tab.mcode`,zcode:`integrations.tab.zcode`,prime:`integrations.tab.prime`},_={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`};function v({apiBase:e,client:n,active:r=!0}){let v=t(),[y,b]=(0,p.useState)(!1),[x,S]=(0,p.useState)(null),[C,w]=(0,p.useState)(null),T=(0,p.useCallback)(t=>d(e,n,t),[e,n]),E=(0,p.useCallback)(async t=>(await s(e,n,t)).operations,[e,n]),D=o(`integration-state:${e}:${n}`,[e,n],T,{isEmpty:()=>!1,enabled:r,sessionCacheKey:`ocx.integrations.state.v1:${e}:${n}`}),O=o(`integration-journal:${e}:${n}`,[e,n],E,{isEmpty:e=>e.length===0,enabled:r,sessionCacheKey:`ocx.integrations.client-journal.v1:${e}:${n}`}),k=D.state.data??null,A=O.state.data??[],j=()=>{D.refresh(),O.refresh()},M=async t=>{if(!(!k||y)){b(!0),S(null);try{await l(e,n,t),j()}catch(e){S(u(v,e))}finally{b(!1)}}},N=()=>void M(!(k&&(k.state===`current`||k.state===`stale`)));if(!k)return(0,m.jsx)(`section`,{className:`integration-client-page`,children:D.state.kind===`failed-cold`?(0,m.jsx)(i,{tone:`err`,children:v(`integrations.error.load`)}):(0,m.jsx)(`p`,{className:`page-sub`,children:v(`common.loading`)})});let P=k.state===`current`||k.state===`stale`,F=!k.installed||k.state===`conflict`||k.state===`unsafe`;return(0,m.jsxs)(`section`,{className:`integration-client-page`,children:[(0,m.jsxs)(`div`,{className:`integration-client-head`,children:[(0,m.jsx)(`h3`,{children:v(g[n])}),(0,m.jsx)(c,{state:k.state,installed:k.installed,id:`integration-state-${n}`}),(0,m.jsx)(a,{on:P,onClick:N,disabled:F||y,label:v(P?`integrations.action.disable`:`integrations.action.apply`)})]}),k.state===`stale`&&(0,m.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void M(!0),disabled:y,children:v(`integrations.action.refresh`)}),(0,m.jsx)(`p`,{className:`page-sub`,children:v(h[n])}),(0,m.jsx)(`p`,{className:`integration-path`,children:k.configPath}),k.appliedAt&&(0,m.jsxs)(`p`,{className:`integration-meta`,children:[v(`integrations.status.appliedAt`),`: `,new Date(k.appliedAt).toLocaleString()]}),k.retentionDegraded&&(0,m.jsx)(i,{tone:`err`,children:v(`integrations.retention.degraded`)}),x&&(0,m.jsx)(i,{tone:`err`,children:x}),(0,m.jsx)(`h4`,{children:v(`integrations.rollback.title`)}),A.length===0?(0,m.jsx)(`p`,{className:`page-sub`,children:v(`integrations.rollback.empty`)}):(0,m.jsx)(`ul`,{className:`integration-history`,children:A.map(e=>(0,m.jsxs)(`li`,{children:[(0,m.jsx)(`span`,{className:`integration-history-kind`,children:v(_[e.kind])}),(0,m.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,m.jsx)(`span`,{className:`badge badge-muted`,children:v(`integrations.action.snapshotExpired`)}):(0,m.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>w(e),children:e.undoable?v(`integrations.action.undo`):v(`integrations.action.restorePoint`)})]},e.opId))}),C&&(0,m.jsx)(f,{apiBase:e,row:C,onClose:()=>w(null),onRestored:j})]})}export{v as default};
@@ -0,0 +1 @@
1
+ import{_ as e,c as t,h as n,m as r}from"./shared-p0R307IX.js";import{F as i,L as a,N as o,P as s,Y as c,bt as l,g as u,m as d}from"./index-CEcmjvjC.js";import{t as f}from"./data-surface-Cq2fDI2w.js";import{t as p}from"./data-surface-D8RXShV2.js";import{n as m,t as h}from"./collapse-store-DnqZvhx0.js";var g=e(n(),1);function _(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 v=r(),y=h(`ocx.grok.collapsedGroups.v2`),b=[{id:`native`,tkey:`grok.groupNative`},{id:`routed`,tkey:`grok.groupRouted`}],x=new Set(b.map(e=>e.id));function S(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 C({apiBase:e,active:n=!0}){let r=t(),h=`ocx.grok.status.v1:${e}`,C=d(h),w=C?.data??null,[T,E]=(0,g.useState)(null),[D,O]=(0,g.useState)(()=>y.read()??new Set(x)),[k,A]=(0,g.useState)(null),[j,M]=(0,g.useState)(null),[N,P]=(0,g.useState)(``),F=(0,g.useCallback)(async t=>{let n=await fetch(`${e}/api/grok`,{signal:t}),i=await o(n,r(`grok.loadFail`));if(!i)throw Error(r(`grok.loadFail`));let a={...i,candidates:i.candidates??[],excluded:i.excluded??[]};return u(h,a),a},[e,h,r]),I=`grok-status:${e}`,L=f(I,[e],F,{isEmpty:()=>!1,initialData:w??void 0,initialDataCachedAt:C?.cachedAt??null,staleAfterMs:6e4,enabled:n}),{state:R}=L,z=L.refresh,B=R.data??w,V=(0,g.useMemo)(()=>new Set(B?.excluded??[]),[B]),H=T??V,U=(0,g.useMemo)(()=>T!==null&&(T.size!==V.size||[...T].some(e=>!V.has(e))),[T,V]),W=(0,g.useMemo)(()=>new Map((B?.models??[]).map(e=>[e.id,e.alias])),[B]),G=e=>{let t=m(D,e);y.write(t),O(t)},K=e=>{let t=e?new Set(b.map(e=>e.id)):new Set;y.write(t),O(t)},q=(e,t)=>{E(n=>{let r=new Set(n??V);return t?r.delete(e):r.add(e),r})},J=async t=>{if(!k){A(`save`),M(null);try{let n=await fetch(`${e}/api/grok/selection`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({excluded:[...H]})});await o(n,r(`grok.saveFailed`));let i=[...H];if(B&&l(I,{...B,excluded:i}),E(null),t){A(`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??r(`grok.applyFailed`))}let n=await t.json().catch(()=>({}));n.skippedReason?(M({tone:`err`,text:n.message??r(`grok.applySkipped`)}),P(n.message??r(`grok.applySkipped`))):(M({tone:`ok`,text:r(`grok.savedApplied`)}),P(r(`grok.savedApplied`))),await z()}else M({tone:`ok`,text:r(`grok.saved`)}),P(r(`grok.saved`)),B&&u(h,{...B,excluded:i})}catch(e){let t=e instanceof Error?e.message:r(`grok.saveFailed`);M({tone:`err`,text:t}),P(t)}finally{A(null)}}};if(R.showSkeleton&&!B)return(0,v.jsx)(`section`,{className:`grok-page`,children:(0,v.jsx)(p,{label:r(`grok.loading`),rows:4})});if(R.kind===`failed-cold`){let e=R.error instanceof Error?R.error.message:r(`grok.loadFail`);return(0,v.jsxs)(`section`,{className:`grok-page`,children:[(0,v.jsx)(`div`,{className:`alert alert-err`,role:`alert`,children:e}),(0,v.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>z(),children:r(`common.retry`)})]})}return(0,v.jsxs)(`section`,{className:`grok-page`,"aria-busy":R.refreshing||void 0,children:[(0,v.jsx)(`h2`,{className:`page-title`,children:r(`grok.title`)}),(0,v.jsx)(`p`,{className:`page-sub`,children:r(`grok.subtitle`)}),(0,v.jsx)(`div`,{className:`sr-only`,"aria-live":`polite`,"aria-atomic":`true`,children:N}),j&&(0,v.jsx)(i,{tone:j.tone,children:j.text}),R.showError&&(0,v.jsx)(i,{tone:`err`,children:r(`grok.loadFail`)}),B&&B.candidates.length>0&&(0,v.jsxs)(`div`,{className:`claude-profile-bar`,children:[(0,v.jsx)(`span`,{className:`claude-dirty${U?` active`:``}`,children:r(U?`grok.unsaved`:`grok.upToDate`)}),(0,v.jsxs)(`div`,{className:`claude-save-actions`,children:[(0,v.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,disabled:!U||k!==null,onClick:()=>void J(!1),children:r(k===`save`?`grok.saving`:`common.save`)}),(0,v.jsx)(`button`,{type:`button`,className:`btn btn-primary`,disabled:!U||k!==null,onClick:()=>void J(!0),children:r(k===`apply`?`grok.applying`:k===`save`?`grok.saving`:`grok.saveApply`)})]})]}),B?.present?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`grok-endpoint`,children:[(0,v.jsx)(`span`,{children:r(`grok.endpoint`)}),(0,v.jsx)(`code`,{children:B.baseUrl??`—`})]}),(0,v.jsx)(`p`,{className:`page-sub`,children:(0,v.jsx)(`code`,{children:B.configPath})})]}):(0,v.jsxs)(s,{title:r(`grok.notConfiguredTitle`),children:[r(`grok.notConfiguredHint`),(0,v.jsx)(`br`,{}),(0,v.jsx)(`code`,{children:B?.configPath})]}),B&&B.candidates.length>0&&(0,v.jsxs)(`div`,{className:`ocx-group-stack`,children:[(0,v.jsxs)(`div`,{className:`row`,style:{gap:6,margin:`2px 0 10px`},children:[(0,v.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>K(!0),disabled:k!==null,children:[(0,v.jsx)(c,{width:12,height:12,"aria-hidden":`true`}),` `,r(`models.collapseAll`)]}),(0,v.jsxs)(`button`,{type:`button`,className:`btn btn-ghost btn-sm text-caption`,onClick:()=>K(!1),disabled:k!==null,children:[(0,v.jsx)(c,{width:12,height:12,"aria-hidden":`true`,style:{transform:`rotate(90deg)`}}),` `,r(`models.expandAll`)]})]}),b.map(e=>{let t=_(B.candidates,W,H,e.id);if(t.total===0)return null;let n=D.has(e.id);return(0,v.jsxs)(`section`,{className:`ocx-group${n?` collapsed`:``}`,"aria-labelledby":`grok-group-${e.id}`,children:[(0,v.jsx)(`header`,{className:`ocx-group-head${n?``:` open`}`,children:(0,v.jsx)(`h3`,{id:`grok-group-${e.id}`,className:`ocx-group-heading`,children:(0,v.jsxs)(`button`,{type:`button`,className:`ocx-group-toggle`,"aria-expanded":!n,"aria-controls":`grok-group-body-${e.id}`,onClick:()=>G(e.id),children:[(0,v.jsx)(c,{className:`ocx-chevron`,width:14,height:14,"aria-hidden":`true`,style:{transform:n?`none`:`rotate(90deg)`}}),(0,v.jsx)(`span`,{className:`ocx-group-name`,children:r(e.tkey)}),(0,v.jsx)(`span`,{className:`ocx-group-count`,children:r(`grok.enabledCount`,{on:t.enabled,total:t.total})})]})})}),!n&&(0,v.jsx)(`div`,{id:`grok-group-body-${e.id}`,className:`grok-model-list`,children:t.rows.map(e=>(0,v.jsxs)(`div`,{className:`grok-model-row`,children:[(0,v.jsx)(a,{on:e.enabled,onClick:()=>q(e.id,!e.enabled),disabled:k!==null,label:r(`grok.toggleModel`,{id:e.id})}),(0,v.jsxs)(`span`,{className:`grok-model-names`,children:[(0,v.jsx)(`strong`,{title:e.id,children:e.id}),(0,v.jsx)(`code`,{title:e.alias??void 0,children:e.alias??`—`})]}),(0,v.jsx)(`span`,{className:`claude-model-context`,children:S(e.contextWindow,r)})]},e.id))})]},e.id)})]})]})}export{C as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ApiKeys-nJ-qJbkG.js","assets/shared-p0R307IX.js","assets/index-CEcmjvjC.js","assets/index-pLho_LBF.css","assets/data-surface-Cq2fDI2w.js","assets/data-surface-D8RXShV2.js","assets/section-tabs-DEASco68.js","assets/Claude-Br34aNO2.js","assets/model-display-CTtXLqIv.js","assets/collapse-store-DnqZvhx0.js","assets/Grok-pTPUqi3L.js","assets/IntegrationsOverview-C6Mkt8OU.js","assets/RestoreDialog-BnPA60nS.js","assets/FileIntegrationPage-8JuhUwT7.js"])))=>i.map(i=>d[i]);
2
+ import{_ as e,c as t,h as n,m as r}from"./shared-p0R307IX.js";import{B as i,V as a,l as o,t as s}from"./index-CEcmjvjC.js";var c=e(n(),1),l=r(),u=(0,c.lazy)(()=>s(()=>import(`./ApiKeys-nJ-qJbkG.js`),__vite__mapDeps([0,1,2,3,4,5,6]))),d=(0,c.lazy)(()=>s(()=>import(`./Claude-Br34aNO2.js`),__vite__mapDeps([7,1,2,3,4,5,8,9]))),f=(0,c.lazy)(()=>s(()=>import(`./Grok-pTPUqi3L.js`),__vite__mapDeps([10,1,2,3,4,5,9]))),p=(0,c.lazy)(()=>s(()=>import(`./IntegrationsOverview-C6Mkt8OU.js`),__vite__mapDeps([11,1,2,3,4,12]))),m=(0,c.lazy)(()=>s(()=>import(`./FileIntegrationPage-8JuhUwT7.js`),__vite__mapDeps([13,1,2,3,4,12]))),h=[{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`},{id:`dsh`,hash:`integrations/dsh`,labelKey:`integrations.tab.dsh`},{id:`mcode`,hash:`integrations/mcode`,labelKey:`integrations.tab.mcode`},{id:`zcode`,hash:`integrations/zcode`,labelKey:`integrations.tab.zcode`},{id:`prime`,hash:`integrations/prime`,labelKey:`integrations.tab.prime`}],g=new Set([`opencode`,`pi`,`omp`,`hermes`,`openclaw`,`kimi`,`gajae`,`dsh`,`mcode`,`zcode`,`prime`]);function _(e=window.location.hash){let t=a(e);return t===`integrations/claude/desktop`?`claude`:h.find(e=>e.hash===t)?.id??`overview`}function v(e){return`integrations-tab-${e}`}function y(e){return`integrations-panel-${e}`}function b({apiBase:e}){let n=t(),[r,a]=(0,c.useState)(_),[s,b]=(0,c.useState)(()=>new Set([_()])),x=(0,c.useRef)(null);x.current===null&&(x.current=new Map);let S=e=>{a(e),b(t=>t.has(e)?t:new Set([...t,e]))};(0,c.useEffect)(()=>{let e=()=>S(_());return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[]);let C=(e,t)=>{let n=h.find(t=>t.id===e);n&&(i(n.hash),S(e),t&&window.requestAnimationFrame(()=>{x.current.get(e)?.focus({preventScroll:!0})}))},w=e=>{let t=h.findIndex(e=>e.id===r),n=null;e.key===`ArrowLeft`?n=(t-1+h.length)%h.length:e.key===`ArrowRight`?n=(t+1)%h.length:e.key===`Home`?n=0:e.key===`End`&&(n=h.length-1),n!==null&&(e.preventDefault(),C(h[n].id,!0))};return(0,l.jsxs)(`section`,{className:`integrations-page`,children:[(0,l.jsx)(`div`,{className:`page-head`,children:(0,l.jsx)(`h2`,{children:n(`nav.integrations`)})}),(0,l.jsx)(`p`,{className:`page-sub`,children:n(`integrations.subtitle`)}),(0,l.jsx)(`div`,{className:`page-tabs`,role:`tablist`,"aria-label":n(`integrations.tabsLabel`),children:h.map(e=>(0,l.jsx)(`button`,{ref:t=>{t?x.current.set(e.id,t):x.current.delete(e.id)},type:`button`,role:`tab`,id:v(e.id),"aria-selected":r===e.id,"aria-controls":y(e.id),tabIndex:r===e.id?0:-1,className:`page-tab${r===e.id?` page-tab--active`:``}`,onClick:()=>C(e.id,!0),onKeyDown:w,children:n(e.labelKey)},e.id))}),h.map(t=>{if(!s.has(t.id))return null;let a=r===t.id;return(0,l.jsx)(`div`,{role:`tabpanel`,id:y(t.id),"aria-labelledby":v(t.id),hidden:!a,children:(0,l.jsx)(o,{pageName:n(t.labelKey),title:n(`errorBoundary.title`),message:n(`errorBoundary.message`),detailsLabel:n(`errorBoundary.details`),reloadLabel:n(`errorBoundary.reload`),onReload:()=>window.location.reload(),children:(0,l.jsxs)(c.Suspense,{fallback:(0,l.jsxs)(`div`,{className:`route-loading`,"aria-busy":`true`,children:[(0,l.jsx)(`span`,{className:`spin`,"aria-hidden":`true`}),n(`common.loading`)]}),children:[t.id===`overview`&&(0,l.jsx)(p,{apiBase:e,active:a}),t.id===`keys`&&(0,l.jsx)(u,{apiBase:e,active:a}),t.id===`codex`&&(0,l.jsxs)(`section`,{className:`integration-native-page`,"aria-labelledby":`codex-integration-title`,children:[(0,l.jsx)(`h3`,{id:`codex-integration-title`,children:n(`integrations.codex.title`)}),(0,l.jsx)(`p`,{children:n(`integrations.codex.body`)}),(0,l.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>i(`startup`),children:n(`integrations.codex.openService`)})]}),t.id===`claude`&&(0,l.jsx)(d,{apiBase:e,active:a}),t.id===`grok`&&(0,l.jsx)(f,{apiBase:e,active:a}),g.has(t.id)&&(0,l.jsx)(m,{apiBase:e,client:t.id,active:a})]})})},t.id)})]})}export{b as default};
@@ -0,0 +1,3 @@
1
+ import{_ as e,c as t,h as n,m as r}from"./shared-p0R307IX.js";import{B as i,F as a,L as o}from"./index-CEcmjvjC.js";import{t as s}from"./data-surface-Cq2fDI2w.js";import{a as c,c as l,d as u,f as d,g as f,h as p,i as m,l as ee,m as h,n as g,o as _,r as v,s as te,t as ne,u as re}from"./RestoreDialog-BnPA60nS.js";var y=e(n(),1),b=r();function x({copyKey:e,vars:n}){let r=t()(e,n),i=n?.path;if(!i||!r.includes(i))return(0,b.jsx)(`p`,{children:r});let[a,...o]=r.split(i);return(0,b.jsxs)(`p`,{children:[a,(0,b.jsx)(`code`,{children:i}),o.join(i)]})}function ie({copy:e,onConfirm:n,onClose:r}){let i=t(),o=(0,y.useRef)(null),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),d=`integration-consequence-dialog-title`;(0,y.useEffect)(()=>{let e=o.current;return e&&!e.open&&e.showModal(),()=>{e?.open&&e.close()}},[]);let f=(0,y.useCallback)(e=>{e.preventDefault(),s||r()},[r,s]),p=(0,y.useCallback)(async()=>{if(!s){c(!0),u(null);try{await n()}catch(e){u(e instanceof Error?e.message:i(`integrations.error.generic`)),c(!1)}}},[n,s,i]),m=[(0,b.jsx)(x,{copyKey:e.changesKey,vars:e.vars},`changes`),(0,b.jsx)(x,{copyKey:e.breakageKey,vars:e.vars},`breakage`),(0,b.jsx)(x,{copyKey:e.undoKey,vars:e.vars},`undo`)];return e.sideEffectKey&&m.push((0,b.jsx)(x,{copyKey:e.sideEffectKey,vars:e.vars},`side-effect`)),(0,b.jsxs)(`dialog`,{ref:o,className:`modal-overlay`,"aria-labelledby":d,onCancel:f,children:[(0,b.jsx)(`button`,{type:`button`,className:`modal-backdrop-dismiss`,"aria-label":i(`common.close`),tabIndex:-1,onClick:()=>{s||r()}}),(0,b.jsxs)(`div`,{className:`modal-card integration-consequence-dialog`,role:`document`,children:[(0,b.jsxs)(`div`,{className:`modal-head`,children:[(0,b.jsx)(`h3`,{id:d,children:i(e.titleKey,e.vars)}),(0,b.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:r,disabled:s,children:i(`common.close`)})]}),(0,b.jsx)(`div`,{className:`integration-consequence-body`,children:m}),l&&(0,b.jsx)(a,{tone:`err`,children:l}),(0,b.jsx)(`div`,{className:`modal-actions`,children:(0,b.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>void p(),disabled:s,children:i(e.confirmKey)})})]})]})}var S={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`,dsh:`integrations.tab.dsh`,mcode:`integrations.tab.mcode`,zcode:`integrations.tab.zcode`,prime:`integrations.tab.prime`};function C(e){return e===`current`||e===`stale`}function w(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??null,detailKey:e.recommendedCommand?null:`integrations.detail.codexAbsent`}:{...t,state:`unknown`,installed:!1,applied:!1,detailKey:null}}function T(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 E(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 D(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=E(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 O(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(!i)return e.applied===!0||e.driftReason===`desired_off_gateway_selected`?{...r,state:`stale`,installed:e.installed===!0,applied:!0,toggleOn:!1,detailKey:`integrations.detail.desktopDesiredOffCleanupPending`}:{...r,state:`absent`,installed:e.installed===!0,applied:!1,toggleOn:!1,detailKey:`integrations.detail.desktopDesiredOff`};if(e.applied!==!0)return{...r,state:`absent`,installed:e.installed===!0,applied:!1,toggleOn:i,detailKey:`integrations.detail.desktopDesiredOnNotApplied`};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 k(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 A(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=k(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 j(e){return{id:e.clientId,hash:`integrations/${e.clientId}`,labelKey:S[e.clientId],state:e.installed?e.state:`not-installed`,installed:e.installed,applied:e.installed&&C(e.state),detail:e.configPath,detailKey:null,detailVars:null,toggle:e.clientId,toggleBlocked:null,togglePath:e.configPath,status:e}}function ae(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=[w(e.codex),D(e.claude,t,e.nativeSettled),O(e.claudeDesktop,e.native?.find(e=>e.clientId===`claude-desktop`),e.nativeSettled),A(e.grok,n,e.nativeSettled)];for(let t of _){let n=r.get(t);if(n){i.push(j(n));continue}e.clientsSettled||i.push({id:t,hash:`integrations/${t}`,labelKey:S[t],state:`unknown`,installed:!1,applied:!1,detail:null,detailKey:null,detailVars:null,toggle:null,toggleBlocked:null,togglePath:null,status:null})}return{keysRow:T(e.keyPhase,e.keyCount),rows:i}}function oe(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 se={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`},ce={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`},le={apply:`integrations.kind.apply`,disable:`integrations.kind.disable`,refresh:`integrations.kind.refresh`,restore:`integrations.kind.restore`};function M(e){return e.state===`current`||e.state===`stale`}function ue({row:e,pending:n,result:r,onOpen:i,onToggle:s}){let c=t(),l=e.detail??(e.detailKey?c(e.detailKey,e.detailVars??void 0):null),u=e.toggleBlocked!==null&&(e.applied||e.toggleBlocked.reason===`orphaned_marker`),d=u&&e.toggleBlocked&&(e.toggle===`claude`||e.toggle===`grok`)?g(c,new v(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,b.jsxs)(`li`,{className:`integration-card`,"data-client":e.id,children:[(0,b.jsxs)(`div`,{className:`integration-card-head`,children:[(0,b.jsx)(`h4`,{children:(0,b.jsx)(`button`,{type:`button`,className:`integration-card-link`,onClick:i,children:c(e.labelKey)})}),(0,b.jsx)(f,{state:e.state,installed:e.installed})]}),l&&(0,b.jsx)(`p`,{className:e.detail?`integration-path`:`integration-meta`,children:l}),r?.tone===`err`&&(0,b.jsx)(a,{tone:`err`,children:r.text}),r?.tone===`ok`&&(0,b.jsx)(a,{tone:`ok`,children:r.text}),(0,b.jsxs)(`div`,{className:`integration-card-actions`,children:[e.toggle&&s&&(0,b.jsxs)(`div`,{className:`integration-toggle-control`,children:[(0,b.jsx)(o,{on:e.toggleOn??e.applied,onClick:s,disabled:e.state===`unknown`||!e.installed||e.state===`conflict`||e.state===`unsafe`||u||n,label:e.applied?c(`integrations.action.disable`):c(`integrations.action.apply`)}),d&&(0,b.jsx)(`p`,{className:`integration-toggle-blocked`,children:d})]}),(0,b.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:i,tabIndex:-1,children:c(`integrations.action.settings`)})]})]})}function N({apiBase:e,active:n=!0}){let r=t(),[o,f]=(0,y.useState)(!1),[_,v]=(0,y.useState)(null),[x,S]=(0,y.useState)(null),[C,w]=(0,y.useState)({}),[T,E]=(0,y.useState)(null),D=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(T!==null)return;let e=D.current;e&&(D.current=null,e.isConnected&&e.focus())},[T]);let O=(0,y.useCallback)(async t=>(await h(e,t)).clients,[e]),k=(0,y.useCallback)(async t=>(await d(e,void 0,t)).operations,[e]),A=(0,y.useCallback)(t=>re(e,t),[e]),j=(0,y.useCallback)(t=>te(e,t),[e]),N=(0,y.useCallback)(t=>l(e,t),[e]),fe=(0,y.useCallback)(t=>ee(e,t),[e]),pe=(0,y.useCallback)(t=>u(e,t),[e]),me=(0,y.useCallback)(async t=>(await m(e,t))?.clients??null,[e]),P=s(`integration-states:${e}`,[e],O,{isEmpty:e=>e.length===0,enabled:n,sessionCacheKey:`ocx.integrations.states.v1:${e}`}),F=s(`integration-journal-all:${e}`,[e],k,{isEmpty:e=>e.length===0,enabled:n,sessionCacheKey:`ocx.integrations.journal.v1:${e}`}),I=s(`integration-codex:${e}`,[e],A,{isEmpty:e=>e===null,enabled:n,sessionCacheKey:`ocx.integrations.codex.v1:${e}`}),L=s(`integration-keys:${e}`,[e],j,{isEmpty:()=>!1,enabled:n,sessionCacheKey:`ocx.integrations.keys.v1:${e}`}),R=s(`integration-claude:${e}`,[e],N,{isEmpty:e=>e===null,enabled:n,sessionCacheKey:`ocx.integrations.claude.v1:${e}`}),he=s(`integration-claude-desktop:${e}`,[e],fe,{isEmpty:e=>e===null,enabled:n,sessionCacheKey:`ocx.integrations.claude-desktop.v1:${e}`}),z=s(`integration-grok:${e}`,[e],pe,{isEmpty:e=>e===null,enabled:n,sessionCacheKey:`ocx.integrations.grok.v1:${e}`}),B=s(`integration-native:${e}`,[e],me,{isEmpty:e=>e===null,enabled:n,sessionCacheKey:`ocx.integrations.native.v1:${e}`}),V=P.state.data??[],H=F.state.data??[],U=V.filter(M),ge=V.filter(e=>e.installed),W=P.state.kind!==`cold`&&P.state.kind!==`retrying-cold`,G=B.state.data??null,_e=G!==null,ve=L.state.kind===`cold`||L.state.kind===`retrying-cold`?`checking`:L.state.kind===`failed-cold`||L.state.kind===`failed-with-stale`?`unavailable`:`settled`,{keysRow:ye,rows:K}=ae({clients:V,clientsSettled:W,codex:I.state.data??null,keyCount:L.state.data??null,keyPhase:ve,claude:R.state.data??null,claudeDesktop:he.state.data??null,grok:z.state.data??null,native:G,nativeSettled:_e}),q=oe(K),J=()=>{P.refresh(),F.refresh(),I.refresh(),L.refresh(),R.refresh(),he.refresh(),z.refresh(),B.refresh()},be=async()=>{if(o||U.length===0)return;let t=[r(`integrations.bulk.title`),r(`integrations.bulk.body`)].join(`
2
+
3
+ `);if(!confirm(t))return;f(!0),v(null);let n=[];for(let t of U)try{await p(e,t.clientId,!1)}catch(e){n.push(`${t.clientId}: ${g(r,e)}`)}let i=!1;try{i=(await h(e)).clients.some(M)}catch{n.push(r(`integrations.error.stale`))}i&&n.length===0&&n.push(r(`integrations.error.stale`)),J(),f(!1),v(n.length===0?{tone:`ok`,text:r(`integrations.bulk.success`)}:{tone:`err`,text:r(`integrations.bulk.partial`,{clients:n.join(`; `)})})},Y=H[0]?.at,[X,Z]=(0,y.useState)(null),xe=()=>{B.refresh(),R.refresh(),z.refresh()},Q=(e,t)=>{w(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},$=async(t,n)=>{if(!X&&t.toggle){Z(t.id),Q(t.id,null);try{if(t.status)await p(e,t.status.clientId,n),J();else if(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`){let i=await c(e,t.toggle,n);i.reason===`non_loopback_removed`?Q(t.id,{tone:`ok`,text:r(i.changed?`integrations.native.msg.nonLoopbackRemoved`:`integrations.native.msg.nonLoopbackRemovedNoop`)}):i.reason===`non_loopback_superseded`&&Q(t.id,{tone:`ok`,text:r(`integrations.native.msg.nonLoopbackSuperseded`)}),xe()}}catch(e){Q(t.id,{tone:`err`,text:g(r,e,void 0,t.togglePath??void 0)}),(t.toggle===`claude`||t.toggle===`grok`||t.toggle===`codex`||t.toggle===`claude-desktop`)&&xe()}finally{Z(null)}}},Se=(e,t)=>{if(e.status||t||e.id===`claude`||e.toggle===null){$(e,t);return}let n=document.activeElement;D.current=n?.tagName===`BUTTON`?n:null,E(e)};return(0,b.jsxs)(`section`,{className:`integrations-overview`,children:[(0,b.jsxs)(`div`,{className:`integration-summary`,children:[(0,b.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,b.jsx)(`span`,{className:`integration-summary-label`,children:r(`integrations.summary.detected`)}),(0,b.jsx)(`strong`,{children:q.detected})]}),(0,b.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,b.jsx)(`span`,{className:`integration-summary-label`,children:r(`integrations.summary.applied`)}),(0,b.jsx)(`strong`,{children:q.applied})]}),(0,b.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,b.jsx)(`span`,{className:`integration-summary-label`,children:r(`integrations.summary.stale`)}),(0,b.jsx)(`strong`,{children:q.stale})]}),q.unknown>0&&(0,b.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,b.jsx)(`span`,{className:`integration-summary-label`,children:r(`integrations.state.unknown`)}),(0,b.jsx)(`strong`,{children:q.unknown})]}),(0,b.jsxs)(`div`,{className:`integration-summary-cell`,children:[(0,b.jsx)(`span`,{className:`integration-summary-label`,children:r(`integrations.summary.lastChange`)}),(0,b.jsx)(`strong`,{children:Y?new Date(Y).toLocaleString():r(`integrations.status.unknown`)})]}),(0,b.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>void be(),disabled:o||U.length===0,children:r(`integrations.summary.disableAll`)})]}),(0,b.jsx)(de,{row:ye}),(0,b.jsx)(`p`,{className:`page-sub`,children:r(`integrations.onboarding`)}),P.state.kind===`failed-cold`&&(0,b.jsx)(a,{tone:`err`,children:r(`integrations.error.load`)}),P.state.kind===`failed-with-stale`&&(0,b.jsx)(a,{tone:`err`,children:r(`integrations.error.stale`)}),_&&(0,b.jsx)(a,{tone:_.tone,children:_.text}),K.length===0?P.state.kind===`failed-cold`?null:(0,b.jsx)(`p`,{className:`page-sub`,children:r(`common.loading`)}):(0,b.jsx)(`ul`,{className:`integration-cards`,children:K.map(e=>(0,b.jsx)(ue,{row:e,pending:X!==null,result:C[e.id]??null,onOpen:()=>i(e.hash),onToggle:e.toggle?()=>Se(e,!(e.toggleOn??e.applied)):null},e.id))}),W&&ge.length===0&&(0,b.jsxs)(`div`,{className:`integration-empty`,children:[(0,b.jsx)(`h4`,{children:r(`integrations.empty.title`)}),(0,b.jsx)(`p`,{children:r(`integrations.empty.body`)})]}),(0,b.jsx)(`h4`,{children:r(`integrations.rollback.title`)}),H.length===0?(0,b.jsxs)(`div`,{className:`integration-empty`,children:[(0,b.jsx)(`p`,{children:r(`integrations.rollback.empty`)}),(0,b.jsx)(`p`,{className:`page-sub`,children:r(`integrations.rollback.emptyBody`)})]}):(0,b.jsx)(`ul`,{className:`integration-history`,children:H.map(e=>(0,b.jsxs)(`li`,{children:[(0,b.jsx)(`span`,{className:`integration-history-kind`,children:r(le[e.kind])}),(0,b.jsx)(`span`,{className:`integration-history-client`,children:e.clientId}),(0,b.jsx)(`span`,{className:`integration-history-at`,children:new Date(e.at).toLocaleString()}),e.snapshot===`expired`?(0,b.jsx)(`span`,{className:`badge badge-muted`,children:r(`integrations.action.snapshotExpired`)}):(0,b.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>S(e),children:e.undoable?r(`integrations.action.undo`):r(`integrations.action.restorePoint`)})]},e.opId))}),x&&(0,b.jsx)(ne,{apiBase:e,row:x,onClose:()=>S(null),onRestored:J}),T&&(0,b.jsx)(ie,{copy:{...T.toggle===`claude-desktop`?ce:se,vars:{path:T.togglePath??``}},onClose:()=>E(null),onConfirm:async()=>{await $(T,!1),E(null)}})]})}function de({row:e}){let n=t(),r=e.detailKey?n(e.detailKey,e.detailVars??void 0):null;return(0,b.jsxs)(`div`,{className:`integration-api-keys-row`,"data-client":`keys`,"data-key-state":e.state,children:[(0,b.jsxs)(`div`,{className:`integration-api-keys-copy`,children:[(0,b.jsx)(`h4`,{children:n(e.labelKey)}),r&&(0,b.jsx)(`p`,{className:`integration-meta`,children:r})]}),(0,b.jsx)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:()=>i(e.hash),children:n(`integrations.action.manageKeys`)})]})}export{N as default};