@nextclaw/ui 0.27.4 → 0.27.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/.vite/manifest.json +95 -95
- package/dist/assets/{account-panel-Cfx3ocPY.js → account-panel-C83GDFuy.js} +1 -1
- package/dist/assets/agents-CJA15zzv.js +1 -0
- package/dist/assets/{agents-BdeFtIOV.js → agents-Dr2KkEp2.js} +1 -1
- package/dist/assets/{app-presenter-provider-BB3Xl8b0.js → app-presenter-provider-Cx9MwMtb.js} +17 -16
- package/dist/assets/{appearance-settings-page-DiSRSDN3.js → appearance-settings-page-3IfIzjic.js} +1 -1
- package/dist/assets/apps-CvIlb9Rn.js +1 -0
- package/dist/assets/{confirm-dialog-jz2cQKId.js → confirm-dialog-D30HJBXN.js} +1 -1
- package/dist/assets/{context-menu-C0qywo73.js → context-menu-C6m-WNpl.js} +65 -65
- package/dist/assets/cron-BWZWu80t.js +1 -0
- package/dist/assets/{dialog-DMKYZDFu.js → dialog-DB_l9LK0.js} +1 -1
- package/dist/assets/doc-browser-DQDsmRlr.js +1 -0
- package/dist/assets/inbox-CIsD65lW.js +1 -0
- package/dist/assets/{keyboard-shortcuts-settings-page-BFBXVf20.js → keyboard-shortcuts-settings-page-L4kLGuB8.js} +1 -1
- package/dist/assets/{main-Bp1iozNB.js → main-BNWRrWc_.js} +2 -2
- package/dist/assets/{marketplace-BTDWnHP7.js → marketplace-BH1Sq8dL.js} +1 -1
- package/dist/assets/mcp-marketplace-page-BA-InAbJ.js +1 -0
- package/dist/assets/{model-config-page-CeVvZ29o.js → model-config-page-zqVWyIT0.js} +1 -1
- package/dist/assets/panel-apps-CMX4iWwQ.js +1 -0
- package/dist/assets/{panelStandalone-DomappXm.js → panelStandalone-C38o5B4Q.js} +1 -1
- package/dist/assets/{projects-fPTOn2Wz.js → projects-DNe43T2d.js} +1 -1
- package/dist/assets/{provider-models-D8WOdsdu.js → provider-models-zGsDUBHG.js} +1 -1
- package/dist/assets/{provider-scoped-model-input-BOPkUOtD.js → provider-scoped-model-input-DpEyP1h8.js} +1 -1
- package/dist/assets/{providers-config-page-BilPL0kF.js → providers-config-page-J-1auWPu.js} +1 -1
- package/dist/assets/{pwa-Cp7pPvsZ.js → pwa-jmuWbrqH.js} +1 -1
- package/dist/assets/remote-C7H2o46-.js +1 -0
- package/dist/assets/{runtime-config-page-P5RUq3YK.js → runtime-config-page-CJhqeDcu.js} +1 -1
- package/dist/assets/{service-apps-panel-BReYr_ni.js → service-apps-panel-Dj9okUgp.js} +1 -1
- package/dist/assets/{theme-provider-BsJ6HxeX.js → theme-provider-D4rd-tCP.js} +1 -1
- package/dist/index.html +10 -10
- package/dist/panel-standalone.html +4 -4
- package/package.json +7 -7
- package/src/features/chat/features/message/utils/__tests__/chat-message-timeline.utils.test.ts +16 -0
- package/src/features/chat/features/message/utils/__tests__/chat-message.utils.test.ts +17 -0
- package/src/features/chat/features/message/utils/chat-message-timeline.utils.ts +3 -3
- package/src/features/chat/features/message/utils/chat-message.utils.ts +11 -4
- package/src/features/chat/features/message/utils/chat-user-question-timeline.utils.ts +42 -0
- package/src/features/marketplace/components/detail-doc/__tests__/marketplace-detail-doc.test.tsx +2 -0
- package/src/features/panel-apps/components/panel-app-runtime-surface.tsx +3 -1
- package/src/features/panel-apps/utils/panel-app-doc-browser.utils.tsx +25 -10
- package/src/features/right-panel-resources/components/__tests__/system-object-resource.test.tsx +25 -3
- package/src/features/right-panel-resources/components/native-object-resource.tsx +3 -1
- package/src/features/right-panel-resources/components/system-object-resource.tsx +15 -1
- package/src/features/right-panel-resources/pages/resource-page.tsx +29 -2
- package/src/shared/components/doc-browser/__tests__/doc-browser.test.tsx +16 -13
- package/src/shared/components/doc-browser/doc-browser-renderer.types.ts +3 -0
- package/src/shared/components/doc-browser/doc-browser.tsx +7 -1
- package/src/shared/components/ui/context-menu/context-menu-items.tsx +1 -0
- package/src/shared/components/ui/context-menu/context-menu.tsx +9 -0
- package/dist/assets/agents-p_wcGhC3.js +0 -1
- package/dist/assets/apps-CKFrWb00.js +0 -1
- package/dist/assets/cron-UqsFT41c.js +0 -1
- package/dist/assets/doc-browser-2VjSkax1.js +0 -1
- package/dist/assets/inbox-D62apR2j.js +0 -1
- package/dist/assets/mcp-marketplace-page-oHCbBkS-.js +0 -1
- package/dist/assets/panel-apps-CniMi7QW.js +0 -1
- package/dist/assets/remote-CsJMF8OR.js +0 -1
- package/src/features/panel-apps/components/__tests__/panel-app-toolbar.test.tsx +0 -108
- package/src/features/panel-apps/components/panel-app-toolbar.tsx +0 -89
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DF37yw5_.js";import{Gt as t,Ut as n,Wt as r,Xn as i,Yt as a,Zt as o,_n as s,hn as c,lr as l,ur as u,xr as d}from"./api-CXWxExzS.js";import{t as f}from"./createLucideIcon-C3LSyx-e.js";import{g as p,h as m,ht as h,mt as g,q as _,ut as v}from"./context-menu-C0qywo73.js";import{t as y}from"./search-Dpgv--de.js";import{z as b}from"./dist-D9h2cWk3.js";import{n as x}from"./inbox-CI8ATevA.js";import{i as S,t as C}from"./x-waP-WLuT.js";import{i as w,t as T}from"./use-viewport-layout-Bnm5W5Qz.js";import{t as E}from"./plus-C42o6xrD.js";import{t as D}from"./refresh-cw-DOg2pWGu.js";import{t as O}from"./settings-2-D3-m8a3v.js";import{t as k}from"./trash-2-BVQs-0ji.js";import{l as A,s as j}from"./i18n-ByVUrt9w.js";import{a as M,c as N,g as P,h as F,l as I,o as L,p as R,t as z}from"./provider-models-D8WOdsdu.js";import{n as B,t as V}from"./status-dot-DlELD18e.js";import{t as H}from"./confirm-dialog-jz2cQKId.js";import{t as ee}from"./host-capabilities-B107nwS3.js";import{a as U,i as W,n as G,r as K,t as q}from"./select-BJ-EjmCz.js";import{a as J,c as te,d as ne,f as re,h as ie,i as ae,l as oe,m as se,o as ce,p as le,r as ue,y as de}from"./use-config-M1L4xn8c.js";import{t as fe}from"./form-actions-CZxcWXSm.js";import{t as pe}from"./config-hints-CaB3I7KP.js";import{a as me,c as he,i as ge,l as _e,n as ve,o as ye,r as be,s as xe}from"./config-split-page-BaHtm9OW.js";var Se=f(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),Ce=f(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Y=e(d(),1),we={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function X(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function Te(e,t){let n=X(e),r=X(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Z(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function Ee(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function Q(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Ee(n,t))}return n.trim()}function De(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Oe(e,t){return Z(t)}function ke(e,t){return Z(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Ae(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e={},a=N(i.thinking?.supported);if(a.length>0){let t=I(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function je(e,t,n){return{...L(e,n),...L(t,n)}}function Me(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!De([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function Ne(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!Te(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!De(e.models,e.currentEditableModels)||!Me(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function Pe(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=X(e.extraHeaders),a=e.providerDisplayName.trim();return a!==e.effectiveDisplayName&&(t.displayName=a.length>0?a:null),n.length>0&&(t.apiKey=n),r!==e.currentApiBase.trim()&&(t.apiBase=r.length>0&&r!==e.defaultApiBase?r:null),Te(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),De(e.models,e.currentEditableModels)||(t.models=ke(e.models,e.providerName??``)),Me(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Ae(e.modelConfig,e.models)),t}function Fe(e){let t=Q(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={...Ie(e),model:t||null};return e.supportsWireApi&&(n.wireApi=e.wireApi),n}function Ie(e){let t={apiBase:e.apiBase.trim(),extraHeaders:X(e.extraHeaders)};return e.apiKey.trim().length>0&&(t.apiKey=e.apiKey.trim()),t}function Le(e){return j(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Re(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function ze(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Be(e,t,n){let r=Q(t,n);return r?e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function Ve(e,t,n){let r=[...e],i=new Set(e);for(let e of t){let t=Q(e,n);t&&!i.has(t)&&(i.add(t),r.push(t))}return{models:r,addedCount:r.length-e.length}}function He(e,t,n){return Ve(e,t,n).models.slice(e.length)}function Ue(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function We(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):z.filter(e=>e===n||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...e};return s.thinking||s.vision===!0?c[t]=s:delete c[t],c}function Ge(e,t,n){let r=e[t],i=r?.thinking;return!i||i.supported.length===0||n&&!i.supported.includes(n)?e:{...e,[t]:{...r,thinking:n?{supported:i.supported,default:n}:{supported:i.supported}}}}function Ke(e,t,n){let r={...e[t],vision:n?!0:void 0},i={...e};return r.thinking||r.vision===!0?i[t]=r:delete i[t],i}function qe(e){let{providerName:t,providerSpec:n,language:r}=e,i=n?.auth,a=i?.methods??[];return{providerAuth:i,providerAuthMethodOptions:a.map(e=>({value:e.id,label:e.label?.[r]||e.label?.en||e.id})),providerAuthMethods:a,preferredAuthMethodId:Re({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:ze({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Je(e,t){let n=!!e?.supportsWireApi||t,r=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:j(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:ze({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:r.length}),supportsWireApi:n,wireApiSelectOptions:r}}function Ye(e){let{providerName:t,providersView:n,templatesView:r,schema:i,language:a}=e,o=t?n?.providers[t]:null,s=r?.providerTemplates.find(e=>e.providerType===o?.providerType),c=o??we,l=i?.uiHints,u=!!o?.isCustom,d=t?pe(`providers.${t}.apiKey`,l):void 0,f=t?pe(`providers.${t}.apiBase`,l):void 0,p=t?pe(`providers.${t}.extraHeaders`,l):void 0,m=t?pe(`providers.${t}.wireApi`,l):void 0,h=s?.displayName||o?.displayName||t||``,g=(c.displayName||``).trim()||h,_=c.enabled!==!1,v=u||s?.supportsModelDiscovery===!0,y=Z([s?.modelPrefix||s?.providerType||``,t||``]),b=s?.defaultApiBase||``,x=c.apiBase||b,S=X(c.extraHeaders||null),C=c.wireApi||s?.defaultWireApi||`auto`,w=Oe(Z((s?.defaultModels??[]).map(e=>Q(e,y))),Z((c.models??[]).map(e=>Q(e,y)))),T=Ae(je(s?.modelConfig,c.modelConfig,y),w),E=s?.apiBaseHelp?.[a]||s?.apiBaseHelp?.en||f?.help||j(`providerApiBaseHelp`),D=qe({providerName:t,providerSpec:s,language:a}),O=Je(s,u);return{apiBaseHelpText:E,apiBaseHint:f,apiKeyHint:d,currentApiBase:x,currentEditableModels:w,currentEnabled:_,currentHeaders:S,currentModelConfig:T,currentWireApi:C,defaultApiBase:b,defaultDisplayName:h,effectiveDisplayName:g,extraHeadersHint:p,...D,providerConfig:o,providerModelAliases:y,resolvedProviderConfig:c,supportsModelDiscovery:v,wireApiHint:m,...O}}function Xe(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:r}=e,a=l(),o=se(),s=oe(),c=te(),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),g=(0,Y.useRef)(null),_=(0,Y.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),v=(0,Y.useCallback)((e,n)=>{_(),g.current=window.setTimeout(()=>{(async()=>{if(t)try{let r=await s.mutateAsync({provider:t,data:{sessionId:e}});if(r.status===`pending`){h(j(`providerAuthWaitingBrowser`)),v(e,r.nextPollMs??n);return}if(r.status===`authorized`){p(null),_(),h(j(`providerAuthCompleted`)),i.success(j(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}p(null),_(),h(r.message||`Authorization ${r.status}.`),i.error(r.message||`Authorization ${r.status}.`)}catch(e){p(null),_();let t=e instanceof Error?e.message:String(e);h(t),i.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[_,s,t,a]),y=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),h(``);let e=await o.mutateAsync({provider:t,data:r?{methodId:r}:{}});if(!e.sessionId||!e.verificationUri)throw Error(j(`providerAuthStartFailed`));p(e.sessionId),h(`${j(`providerAuthOpenPrompt`)}${e.userCode}${j(`providerAuthOpenPromptSuffix`)}`),await ee.openExternalUrl(e.verificationUri),v(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);p(null),_(),h(t),i.error(`${j(`providerAuthStartFailed`)}: ${t}`)}},[_,n?.kind,t,r,v,o]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),_(),p(null);let e=await c.mutateAsync({provider:t});h(`${j(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),i.success(j(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);h(t),i.error(`${j(`providerAuthImportFailed`)}: ${t}`)}},[_,c,n?.kind,t,a]);return(0,Y.useEffect)(()=>{_()},[_,t]),(0,Y.useEffect)(()=>()=>_(),[_]),{authSessionId:u===t?f:null,authStatusMessage:u===t?m:``,importAuthFromCli:b,importPending:c.isPending,startAuth:y,startPending:o.isPending}}function Ze(e){let{providerName:t,apiKey:n,apiKeyRequired:r,apiKeySet:a,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:d,providerModelAliases:f}=e,p=ie(),m=ce(),h=(0,Y.useMemo)(()=>JSON.stringify({providerName:t,apiKey:n,apiBase:o,extraHeaders:s}),[o,n,s,t]),[g,_]=(0,Y.useState)(null),v=(0,Y.useCallback)(async()=>{if(t)try{let e=await p.mutateAsync({provider:t,data:Fe({apiKey:n,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:d,providerModelAliases:f})});if(e.success){i.success(`${j(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let r=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&r.push(`model=${e.model}`),i.error(`${j(`providerTestConnectionFailed`)}: ${e.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);i.error(`${j(`providerTestConnectionFailed`)}: ${t}`)}},[o,n,s,d,f,t,l,p,u]);return{discoverModels:(0,Y.useCallback)(async()=>{if(!t)return null;if(r&&!n.trim()&&!a)return i.error(j(`providerModelsApiKeyRequired`)),null;try{let e=await m.mutateAsync({provider:t,data:Ie({apiKey:n,apiBase:o,extraHeaders:s})});return _({key:h,models:e.models}),i.success(j(`providerModelsFetchSuccess`)),e.models}catch(e){if(e instanceof c&&(e.details?.upstreamStatus===401||e.details?.upstreamStatus===403))return i.error(j(`providerModelsAuthorizationFailed`)),null;let t=e instanceof Error?e.message:String(e);return i.error(`${j(`providerModelsFetchFailed`)}: ${t}`),null}},[o,n,r,a,m,h,s,t]),fetchedModels:g?.key===h?g.models:[],isDiscoveringModels:m.isPending,isTestPending:p.isPending,testConnection:v}}var $=u();function Qe({value:e,onChange:n,className:r}){let i=e?Object.entries(e):[],o=(e,t,r)=>{let a=[...i];a[e]=[t,r],n(Object.fromEntries(a))},c=()=>{n({...e,"":``})},l=e=>{let t=i.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,$.jsxs)(`div`,{className:s(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(t,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:j(`headerName`),className:`flex-1`}),(0,$.jsx)(t,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:j(`headerValue`),className:`flex-1`}),(0,$.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,$.jsx)(k,{className:`h-4 w-4 text-red-500`})})]},r)),(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),j(`add`)]})]})}function $e(e){let{value:t,onChange:n,options:r}=e;return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-[var(--interaction-selection-border)] bg-[var(--interaction-selection)] text-foreground`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-[var(--interaction-hover)] hover:text-foreground`}`,children:e.label},e.value)})})}function et(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:f}=e;return(0,$.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(O,{className:`h-3.5 w-3.5`}),j(`providerAdvancedSettings`)]}),(0,$.jsx)(b,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,$.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,$.jsx)($e,{value:o,onChange:e=>s(e),options:l}):(0,$.jsxs)(q,{value:o,onValueChange:e=>s(e),children:[(0,$.jsx)(W,{className:`rounded-xl`,children:(0,$.jsx)(U,{})}),(0,$.jsx)(G,{children:l.map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))})]})]}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:u}),(0,$.jsx)(Qe,{value:d,onChange:f}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerExtraHeadersHelpShort`)})]})]}):null]})}function tt({isSet:e,className:n,value:r,onChange:i,placeholder:o,...c}){let[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=typeof r==`string`&&r.length>0;return(0,$.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,$.jsx)(`div`,{onClick:()=>f(!0),className:s(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,n),children:`••••••••••••`}):(0,$.jsx)(t,{type:l?`text`:`password`,className:s(`pr-12`,n),value:r,onChange:i,onBlur:()=>{p||f(!1)},placeholder:o,autoFocus:d,...c}),(0,$.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,$.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>u(!l),children:l?(0,$.jsx)(Ce,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})})]})}function nt(e){let{apiKey:t,apiKeyRequired:n,apiKeySet:i,apiKeyPlaceholder:o,providerAuth:s,providerAuthNote:c,providerAuthMethodOptions:l,providerAuthMethodsCount:u,selectedAuthMethodHint:d,shouldUseAuthMethodPills:f,resolvedAuthMethodId:p,onAuthMethodChange:m,onStartProviderAuth:h,onImportProviderAuthFromCli:g,startPending:_,importPending:v,authSessionId:y,authStatusMessage:b,onApiKeyChange:x}=e,S=n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:j(`apiKey`)}),(0,$.jsx)(tt,{id:`apiKey`,value:t,isSet:i,onChange:e=>x(e.target.value),placeholder:o,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`leaveBlankToKeepUnchanged`)})]}):null;return s?.kind===`device_code`?(0,$.jsxs)($.Fragment,{children:[S,(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-muted/45 p-3`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:s.displayName||j(`providerAuthSectionTitle`)}),c?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c}):null,u>1?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{className:`text-xs font-medium text-foreground`,children:j(`providerAuthMethodLabel`)}),f?(0,$.jsx)($e,{value:p,onChange:m,options:l}):(0,$.jsxs)(q,{value:p,onValueChange:m,children:[(0,$.jsx)(W,{className:`h-8 rounded-lg`,children:(0,$.jsx)(U,{placeholder:j(`providerAuthMethodPlaceholder`)})}),(0,$.jsx)(G,{children:l.map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))})]}),d?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:h,disabled:_||!!y,children:j(_?`providerAuthStarting`:y?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),s.supportsCliImport?(0,$.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v,children:j(v?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,y?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[j(`providerAuthSessionLabel`),`: `,y.slice(0,8),`…`]}):null]}),b?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b}):null]})]}):S}function rt(e){let{providerName:t,models:n,aliases:r,fetchedModels:i=[],onModelsChange:a}=e,o=ne({pollWhileRefreshing:!0,refreshOnMount:!0}),s=t?o.data?.providers[t]:void 0,c=i.length>0?`fetched`:`background`,l=(0,Y.useMemo)(()=>He(n,c===`fetched`?i:s?.models??[],r),[r,s?.models,i,n,c]);return{addSuggestedModels:(0,Y.useCallback)(e=>{let t=Ve(n,e,r);t.addedCount>0&&a(t.models)},[r,n,a]),hasSuggestionError:!!(s?.lastError&&!s.fetchedAt),isCheckingSuggestions:!!(t&&(o.isLoading||o.data?.refreshing&&!s)),suggestedModels:l,suggestionSource:c}}function it(e){let{models:t,modelConfig:i,onModelsChange:a,onRemoveModel:o,onToggleModelThinkingLevel:s,onSetModelThinkingDefault:c,onSetModelVision:l,thinkingLevels:u,formatThinkingLevelLabel:d}=e,[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(()=>new Set),g=(0,Y.useMemo)(()=>t.filter(e=>m.has(e)),[t,m]),_=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=()=>{p(!1),h(new Set)};return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-center justify-end gap-2`,children:f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:j(`providerModelsSuggestionsSelected`).replace(`{count}`,String(g.length))}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:text-primary/80`,onClick:()=>h(g.length===t.length?new Set:new Set(t)),children:j(g.length===t.length?`providerModelsClearSelection`:`providerModelsSelectAll`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:v,children:j(`cancel`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:g.length===0,className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>{g.length!==0&&(a(t.filter(e=>!m.has(e))),v())},children:[(0,$.jsx)(k,{className:`h-3 w-3`}),j(`providerModelsRemoveSelected`)]})]}):(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>p(!0),children:[(0,$.jsx)(k,{className:`h-3 w-3`}),j(`providerModelsBulkRemove`)]})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{if(f)return(0,$.jsxs)(`label`,{className:`inline-flex max-w-full cursor-pointer items-center gap-2 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5 hover:bg-[var(--interaction-hover)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:m.has(e),onChange:()=>_(e),"aria-label":j(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e})]},e);let t=i[e],a=t?.thinking,p=a?.supported??[],h=a?.default??null,g=t?.vision===!0;return(0,$.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,$.jsxs)(R,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-[var(--interaction-hover)] hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":j(`providerModelThinkingTitle`),title:j(`providerModelThinkingTitle`),children:(0,$.jsx)(O,{className:`h-3 w-3`})})}),(0,$.jsxs)(F,{className:`w-80 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:j(`providerModelVisionTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelVisionHint`)})]}),(0,$.jsx)(n,{checked:g,onCheckedChange:t=>l(e,t)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:j(`providerModelThinkingTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelThinkingHint`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${p.includes(t)?`border-[var(--interaction-selection-border)] bg-[var(--interaction-selection)] text-foreground`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-[var(--interaction-hover)] hover:text-foreground`}`,children:d(t)},t))}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(r,{className:`text-xs font-medium text-foreground`,children:j(`providerModelThinkingDefault`)}),(0,$.jsxs)(q,{value:h??`__none__`,onValueChange:t=>c(e,t===`__none__`?null:t),disabled:p.length===0,children:[(0,$.jsx)(W,{className:`h-8 rounded-lg text-xs`,children:(0,$.jsx)(U,{})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{value:`__none__`,children:j(`providerModelThinkingDefaultNone`)}),p.map(e=>(0,$.jsx)(K,{value:e,children:d(e)},e))]})]}),p.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-[var(--interaction-hover)] hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":j(`remove`),children:(0,$.jsx)(C,{className:`h-3 w-3`})})]},e)})}),f?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelsRemoveSaveHint`)}):null]})}var at=20,ot=50,st=50;function ct(e){let{expanded:n,fetchedTotal:r,models:i,source:a,onExpandedChange:o,onAddModels:s}=e,[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(()=>new Set),f=(0,Y.useMemo)(()=>{let e=c.trim().toLowerCase();return e?i.filter(t=>t.toLowerCase().includes(e)):i},[i,c]),p=f.slice(0,st),m=(0,Y.useMemo)(()=>i.filter(e=>u.has(e)),[i,u]),g=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=e=>{e.length!==0&&(s(e),l(``),d(new Set))},b=a===`fetched`?`providerModelsFetchedSuggestionsSummary`:`providerModelsSuggestionsSummary`;return a===`fetched`&&i.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,role:`status`,children:[(0,$.jsx)(_,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{children:j(`providerModelsFetchedAllConfigured`).replace(`{count}`,String(r))})]}):(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":n,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground`,onClick:()=>o(!n),children:[(0,$.jsx)(_,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j(b).replace(`{count}`,String(i.length))}),(0,$.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${n?`rotate-90`:``}`})]}),i.length<=ot?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg px-2 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-[var(--interaction-hover)]`,onClick:()=>v(i),children:j(`providerModelsSuggestionsAddAll`)}):null]}),n?(0,$.jsxs)(`div`,{className:`px-1 pb-1`,children:[i.length>at?(0,$.jsxs)(`div`,{className:`relative px-2 pb-1 pt-1.5`,children:[(0,$.jsx)(y,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(t,{value:c,onChange:e=>l(e.target.value),placeholder:j(`providerModelsSuggestionsSearchPlaceholder`),className:`h-8 rounded-lg pl-8 text-xs`})]}):null,(0,$.jsxs)(`div`,{className:`custom-scrollbar max-h-44 overflow-y-auto`,children:[p.map(e=>(0,$.jsxs)(`label`,{className:`grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-[var(--interaction-hover)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>g(e),"aria-label":j(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-xs text-foreground`,title:e,children:e})]},e)),f.length===0?(0,$.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-muted-foreground`,children:j(`providerModelsSuggestionsSearchEmpty`)}):null]}),f.length>p.length?(0,$.jsx)(`p`,{className:`px-2 pt-1 text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsShowing`).replace(`{visible}`,String(p.length)).replace(`{count}`,String(f.length))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pt-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsSelected`).replace(`{count}`,String(m.length))}),(0,$.jsx)(`button`,{type:`button`,disabled:m.length===0,className:`shrink-0 rounded-md bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary transition-colors hover:bg-[var(--interaction-hover)] disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>v(m),children:j(`providerModelsSuggestionsAddSelected`)})]}),(0,$.jsx)(`p`,{className:`px-2 pb-1 pt-1 text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsSaveHint`)})]}):null]})}function lt({hasFetchedCatalog:e,hasSuggestionError:t,supportsModelDiscovery:n}){return!n||!t||e?null:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(g,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),j(`providerModelsSuggestionsFailed`)]})}function ut(e){let{providerName:n,providerModelAliases:i,models:o,modelConfig:s,modelDraft:c,showModelInput:l,onModelDraftChange:u,onShowModelInputChange:d,onAddModel:f,onModelsChange:p,supportsModelDiscovery:m,onDiscoverModels:h,isDiscoveringModels:g,fetchedModels:_,onRemoveModel:v,onToggleModelThinkingLevel:y,onSetModelThinkingDefault:b,onSetModelVision:x,thinkingLevels:w,formatThinkingLevelLabel:T}=e,[O,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),{addSuggestedModels:M,hasSuggestionError:N,isCheckingSuggestions:P,suggestedModels:F,suggestionSource:I}=rt({providerName:n,models:o,aliases:i,fetchedModels:_,onModelsChange:p}),L=async()=>{await h()&&(k(!0),window.requestAnimationFrame(()=>{let e=A.current;e?.scrollIntoView?.({behavior:`smooth`,block:`center`}),e?.focus({preventScroll:!0})}))},R=_.length>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:j(`providerModelsTitle`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[m?(0,$.jsxs)(`button`,{type:`button`,onClick:L,disabled:g,className:`flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:text-primary/80 disabled:cursor-wait disabled:opacity-60`,children:[(0,$.jsx)(D,{className:`h-3 w-3 ${g?`animate-spin`:``}`}),j(g?`providerModelsFetching`:`providerModelsFetch`)]}):null,l?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),j(`providerAddModel`)]})]})]}),l?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(t,{value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(d(!1),u(``))},placeholder:j(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,$.jsx)(a,{type:`button`,size:`sm`,onClick:f,disabled:c.trim().length===0,children:j(`add`)}),(0,$.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{d(!1),u(``)},children:(0,$.jsx)(C,{className:`h-4 w-4`})})]}):null,(0,$.jsx)(lt,{hasFetchedCatalog:R,hasSuggestionError:N,supportsModelDiscovery:m}),m&&P&&!R?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`}),j(`providerModelsSuggestionsChecking`)]}):m&&(F.length>0||R)?(0,$.jsx)(`div`,{ref:A,tabIndex:-1,"aria-live":`polite`,className:`scroll-m-4 outline-none`,children:(0,$.jsx)(ct,{expanded:O,fetchedTotal:_.length,models:F,source:I,onExpandedChange:k,onAddModels:M})}):null,o.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j(`providerModelsEmptyShort`)}),l?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:j(`providerAddFirstModel`)})]}):(0,$.jsx)(it,{models:o,modelConfig:s,onModelsChange:p,onRemoveModel:v,onToggleModelThinkingLevel:y,onSetModelThinkingDefault:b,onSetModelVision:x,thinkingLevels:w,formatThinkingLevelLabel:T})]})}function dt({apiKeyRequired:e=!0,apiKeySet:t,className:n,enabled:r}){if(!r)return(0,$.jsx)(V,{status:`inactive`,label:j(`disabled`),className:n});let i=!e||t;return(0,$.jsx)(V,{status:i?`ready`:`setup`,label:j(i?`statusReady`:`statusSetup`),className:n})}function ft(e){let{context:n,language:i,providerTitle:o,providerDisplayName:s,apiKey:c,apiBase:l,extraHeaders:u,wireApi:d,models:f,modelConfig:p,modelDraft:m,showAdvanced:h,showModelInput:g,resolvedAuthMethodId:_,authSessionId:v,authStatusMessage:y,hasChanges:b,isDeletePending:x,isUpdatePending:S,connectivity:C,startPending:w,importPending:T,onProviderDisplayNameChange:E,onApiKeyChange:D,onApiBaseChange:O,onAuthMethodChange:A,onStartProviderAuth:M,onImportProviderAuthFromCli:N,onModelDraftChange:P,onShowModelInputChange:F,onAddModel:I,onModelsChange:L,onRemoveModel:R,onToggleModelThinkingLevel:B,onSetModelThinkingDefault:V,onSetModelVision:H,onShowAdvancedChange:ee,onWireApiChange:U,onExtraHeadersChange:W,onDeleteProvider:G,onSubmit:K,onTestConnection:q}=e,J=n.providerAuthMethods.find(e=>e.id===_);return(0,$.jsxs)(ve,{children:[(0,$.jsx)(he,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:o}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:G,disabled:x,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:j(`providerDelete`),children:(0,$.jsx)(k,{className:`h-4 w-4`})}),(0,$.jsx)(dt,{enabled:n.currentEnabled,apiKeyRequired:n.resolvedProviderConfig.apiKeyRequired,apiKeySet:n.resolvedProviderConfig.apiKeySet})]})]})}),(0,$.jsxs)(`form`,{onSubmit:K,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(ye,{className:`space-y-4 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:j(`providerDisplayName`)}),(0,$.jsx)(t,{id:`providerDisplayName`,type:`text`,value:s,onChange:e=>E(e.target.value),placeholder:n.defaultDisplayName||j(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerDisplayNameHelpShort`)})]}),(0,$.jsx)(nt,{apiKey:c,apiKeyRequired:n.resolvedProviderConfig.apiKeyRequired!==!1,apiKeySet:n.resolvedProviderConfig.apiKeySet,apiKeyPlaceholder:n.apiKeyHint?.placeholder??j(`enterApiKey`),providerAuth:n.providerAuth,providerAuthNote:n.providerAuth?.note?.[i]||n.providerAuth?.note?.en||n.providerAuth?.displayName||``,providerAuthMethodOptions:n.providerAuthMethodOptions,providerAuthMethodsCount:n.providerAuthMethods.length,selectedAuthMethodHint:J?.hint?.[i]||J?.hint?.en||``,shouldUseAuthMethodPills:n.shouldUseAuthMethodPills,resolvedAuthMethodId:_,onAuthMethodChange:A,onStartProviderAuth:M,onImportProviderAuthFromCli:N,startPending:w,importPending:T,authSessionId:v,authStatusMessage:y,onApiKeyChange:D}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:j(`apiBase`)}),(0,$.jsx)(t,{id:`apiBase`,type:`text`,value:l,onChange:e=>O(e.target.value),placeholder:n.defaultApiBase||n.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.apiBaseHelpText})]}),(0,$.jsx)(ut,{providerName:n.providerConfig?.providerId??``,providerModelAliases:n.providerModelAliases,models:f,modelConfig:p,modelDraft:m,showModelInput:g,onModelDraftChange:P,onShowModelInputChange:F,onAddModel:I,onModelsChange:L,supportsModelDiscovery:n.supportsModelDiscovery,onDiscoverModels:C.discoverModels,isDiscoveringModels:C.isDiscoveringModels,fetchedModels:C.fetchedModels,onRemoveModel:R,onToggleModelThinkingLevel:B,onSetModelThinkingDefault:V,onSetModelVision:H,thinkingLevels:z,formatThinkingLevelLabel:Le},n.providerConfig?.providerId),(0,$.jsx)(et,{showAdvanced:h,onShowAdvancedChange:ee,supportsWireApi:n.supportsWireApi,wireApiLabel:j(`wireApi`),wireApi:d,onWireApiChange:U,shouldUseWireApiPills:n.shouldUseWireApiPills,wireApiSelectOptions:n.wireApiSelectOptions,extraHeadersLabel:j(`extraHeaders`),extraHeaders:u,onExtraHeadersChange:W})]}),(0,$.jsx)(xe,{children:(0,$.jsxs)(fe,{align:`between`,children:[(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:q,disabled:C.isTestPending,children:[(0,$.jsx)(Se,{className:`mr-1.5 h-3.5 w-3.5`}),C.isTestPending?j(`providerTestingConnection`):j(`providerTestConnection`)]}),(0,$.jsx)(a,{type:`submit`,size:`sm`,disabled:S||!b,children:j(S?`saving`:b?`save`:`unchanged`)})]})})]})]})}function pt({providerName:e,onProviderDeleted:t}){let{data:n}=le(),{data:r}=re(),{data:i}=ue(),a=A(),o=(0,Y.useMemo)(()=>Ye({providerName:e,providersView:n,templatesView:r,schema:i,language:a}),[a,e,n,i,r]);if(!e||!o.providerConfig)return(0,$.jsx)(be,{children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:j(`providersSelectTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:j(`providersSelectDescription`)})]})});let s=JSON.stringify({providerConfig:o.providerConfig,currentApiBase:o.currentApiBase,currentEditableModels:o.currentEditableModels,currentModelConfig:o.currentModelConfig,currentWireApi:o.currentWireApi,effectiveDisplayName:o.effectiveDisplayName,preferredAuthMethodId:o.preferredAuthMethodId});return(0,$.jsx)(mt,{providerName:e,onProviderDeleted:t,context:o,language:a},s)}function mt({providerName:e,onProviderDeleted:t,context:n,language:r}){let i=de(),a=J(),{currentApiBase:o,currentEditableModels:s,currentHeaders:c,currentModelConfig:l,currentWireApi:u,defaultApiBase:d,effectiveDisplayName:f,providerAuth:p,providerAuthMethods:m,providerModelAliases:h,resolvedProviderConfig:g,preferredAuthMethodId:_,supportsWireApi:v}=n,[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(o),[C,w]=(0,Y.useState)(g.extraHeaders||null),[T,E]=(0,Y.useState)(u),[D,O]=(0,Y.useState)(s),[k,A]=(0,Y.useState)(l),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(f),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,V]=(0,Y.useState)(_),H=Ze({providerName:e,apiKey:y,apiKeyRequired:g.apiKeyRequired!==!1,apiKeySet:g.apiKeySet,apiBase:x,extraHeaders:C,supportsWireApi:v,wireApi:T,models:D,providerModelAliases:h}),ee=P.trim()||f||e||j(`providersSelectPlaceholder`),U=(0,Y.useMemo)(()=>{if(!m.length)return``;let e=B.trim();return e&&m.some(t=>t.id===e)?e:_||m[0]?.id||``},[B,_,m]),{authSessionId:W,authStatusMessage:G,importAuthFromCli:K,importPending:q,startAuth:te,startPending:ne}=Xe({providerName:e,providerAuth:p,resolvedAuthMethodId:U}),re=(0,Y.useMemo)(()=>Ne({providerName:e,apiKey:y,apiBase:x,currentApiBase:o,extraHeaders:C,currentHeaders:c,supportsWireApi:v,wireApi:T,currentWireApi:u,models:D,currentEditableModels:s,modelConfig:k,currentModelConfig:l,providerDisplayName:P,effectiveDisplayName:f}),[e,y,x,o,C,c,v,T,u,D,s,k,l,P,f]),ie=e=>{O(e),A(t=>Ae(t,e))};return(0,$.jsx)(ft,{context:n,language:r,providerTitle:ee,providerDisplayName:P,apiKey:y,apiBase:x,extraHeaders:C,wireApi:T,models:D,modelConfig:k,modelDraft:M,showAdvanced:I,showModelInput:R,resolvedAuthMethodId:U,authSessionId:W,authStatusMessage:G,hasChanges:re,isDeletePending:a.isPending,isUpdatePending:i.isPending,connectivity:H,startPending:ne,importPending:q,onProviderDisplayNameChange:F,onApiKeyChange:b,onApiBaseChange:S,onAuthMethodChange:V,onStartProviderAuth:te,onImportProviderAuthFromCli:K,onModelDraftChange:N,onShowModelInputChange:z,onAddModel:()=>{let e=Be(D,M,h);ie(e.models),N(e.draft)},onModelsChange:ie,onRemoveModel:e=>{let t=Ue(D,k,e);O(t.models),A(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{A(n=>We(n,e,t))},onSetModelThinkingDefault:(e,t)=>{A(n=>Ge(n,e,t))},onSetModelVision:(e,t)=>{A(n=>Ke(n,e,t))},onShowAdvancedChange:L,onWireApiChange:E,onExtraHeadersChange:w,onDeleteProvider:async()=>{if(e&&window.confirm(j(`providerDeleteConfirm`)))try{await a.mutateAsync({provider:e}),t?.(e)}catch{}},onSubmit:t=>{t.preventDefault(),e&&i.mutate({provider:e,data:Pe({providerName:e,apiKey:y,apiBase:x,currentApiBase:o,defaultApiBase:d,extraHeaders:C,currentHeaders:c,supportsWireApi:v,wireApi:T,currentWireApi:u,models:D,currentEditableModels:s,modelConfig:k,currentModelConfig:l,providerDisplayName:P,effectiveDisplayName:f})})},onTestConnection:H.testConnection})}function ht(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function gt(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function _t(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function vt(){let{isMobile:e}=T(),{data:r}=le(),{data:i}=re(),c=ae(),l=J(),u=de(),[d,f]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)([]),[C,D]=(0,Y.useState)(``),O=(0,Y.useMemo)(()=>gt(Object.values(r?.providers??{}),x),[r?.providers,x]),A=(0,Y.useMemo)(()=>i?.providerTemplates??[],[i?.providerTemplates]),N=(0,Y.useMemo)(()=>_t(A),[A]),I=(0,Y.useMemo)(()=>new Map(A.map(e=>[e.providerType,e])),[A]),L=(0,Y.useMemo)(()=>{let e=C.trim().toLowerCase();return O.filter(t=>{if(!e)return!0;let n=t.providerType?I.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[O,C,I]),z=(0,Y.useMemo)(()=>d&&L.some(e=>e.providerId===d)?d:e?null:L[0]?.providerId??null,[L,e,d]);return!r||!i?(0,$.jsx)(o,{title:j(`providersPageTitle`),description:j(`providersPageDescription`),layout:`split`,children:(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:j(`providersLoading`)})}):(0,$.jsxs)(o,{title:j(`providersPageTitle`),description:j(`providersPageDescription`),layout:`split`,children:[(0,$.jsxs)(me,{className:`md:min-h-0`,compactView:d?`detail`:`list`,onMobileBack:()=>f(null),mobileListLabel:j(`providersPageTitle`),children:[(0,$.jsxs)(_e,{children:[(0,$.jsx)(he,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,$.jsxs)(R,{open:_,onOpenChange:b,children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsxs)(a,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:c.isPending,children:[(0,$.jsx)(E,{className:`mr-2 h-4 w-4`}),c.isPending?j(`saving`):j(`providerAdd`)]})}),(0,$.jsxs)(F,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,$.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:j(`providerTemplatePickerTitle`)}),(0,$.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-left transition-colors hover:border-border hover:bg-[var(--interaction-hover)]`,onClick:async()=>{try{let e=await c.mutateAsync({data:{providerType:null}});D(``),f(e.providerId),S(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),b(!1)}catch{}},children:[(0,$.jsx)(B,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border/60 bg-muted/50`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:j(`providerAddCustom`)})]}),N.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border/55 bg-muted/15 px-3 py-2 text-left transition-colors hover:border-border/80 hover:bg-[var(--interaction-hover)]`,onClick:async()=>{try{let t=await c.mutateAsync({data:{providerType:e.providerType}});D(``),f(t.providerId),S(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),b(!1)}catch{}},children:[(0,$.jsx)(B,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border/55 bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,$.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,$.jsx)(t,{value:C,onChange:e=>D(e.target.value),placeholder:j(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,$.jsxs)(ye,{className:`space-y-2 p-3`,children:[L.map(e=>{let t=e.providerType?I.get(e.providerType):null,r=e.enabled!==!1,i=M(e),a=e.displayName?.trim()||t?.displayName||e.providerId,o=ht(e.apiBase||t?.defaultApiBase||``)||j(`providersDefaultDescription`);return(0,$.jsx)(`div`,{onClick:()=>f(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f(e.providerId))},role:`button`,tabIndex:0,className:s(`group w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,z===e.providerId?`bg-[var(--interaction-selection)] text-foreground`:`bg-transparent text-muted-foreground hover:bg-[var(--interaction-hover)] hover:text-foreground`),children:(0,$.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,$.jsx)(B,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:`h-10 w-10 rounded-lg bg-background/80`,imgClassName:`h-5 w-5 object-contain`,fallback:(0,$.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:a}),(0,$.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,$.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[o,` · `,e.models?.length??0]})]})]}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(n,{checked:r,disabled:u.isPending,title:j(r?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{u.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,$.jsxs)(R,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-[var(--interaction-hover)] hover:text-foreground`,onClick:e=>e.stopPropagation(),title:j(`more`),children:(0,$.jsx)(v,{className:`h-4 w-4`})})}),(0,$.jsx)(F,{variant:`menu`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,className:`${p} ${m.destructive}`,onClick:()=>g(e.providerId),children:[(0,$.jsx)(k,{className:`h-4 w-4`}),j(`providerDelete`)]})})]})]}),(0,$.jsx)(V,{status:r?i?`ready`:`setup`:`inactive`,label:j(r?i?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),L.length===0?(0,$.jsx)(ge,{icon:w,title:j(`providersNoMatch`)}):null]})]}),(0,$.jsx)(pt,{providerName:z??void 0,onProviderDeleted:e=>{S(t=>t.filter(t=>t!==e)),e===z&&f(null)}})]}),(0,$.jsx)(H,{open:!!h,onOpenChange:e=>{e||g(null)},title:j(`providerDelete`),description:h??void 0,confirmLabel:j(`delete`),variant:`destructive`,onCancel:()=>g(null),onConfirm:()=>{h&&l.mutateAsync({provider:h}).then(()=>{S(e=>e.filter(e=>e!==h)),h===z&&f(null),g(null)})}})]})}export{vt as ProvidersConfigPage};
|
|
1
|
+
import{i as e}from"./chunk-DF37yw5_.js";import{Gt as t,Ut as n,Wt as r,Xn as i,Yt as a,Zt as o,_n as s,hn as c,lr as l,ur as u,xr as d}from"./api-CXWxExzS.js";import{t as f}from"./createLucideIcon-C3LSyx-e.js";import{g as p,h as m,ht as h,mt as g,q as _,ut as v}from"./context-menu-C6m-WNpl.js";import{t as y}from"./search-Dpgv--de.js";import{z as b}from"./dist-D9h2cWk3.js";import{n as x}from"./inbox-CI8ATevA.js";import{i as S,t as C}from"./x-waP-WLuT.js";import{i as w,t as T}from"./use-viewport-layout-Bnm5W5Qz.js";import{t as E}from"./plus-C42o6xrD.js";import{t as D}from"./refresh-cw-DOg2pWGu.js";import{t as O}from"./settings-2-D3-m8a3v.js";import{t as k}from"./trash-2-BVQs-0ji.js";import{l as A,s as j}from"./i18n-ByVUrt9w.js";import{a as M,c as N,g as P,h as F,l as I,o as L,p as R,t as z}from"./provider-models-zGsDUBHG.js";import{n as B,t as V}from"./status-dot-DlELD18e.js";import{t as H}from"./confirm-dialog-D30HJBXN.js";import{t as ee}from"./host-capabilities-B107nwS3.js";import{a as U,i as W,n as G,r as K,t as q}from"./select-BJ-EjmCz.js";import{a as J,c as te,d as ne,f as re,h as ie,i as ae,l as oe,m as se,o as ce,p as le,r as ue,y as de}from"./use-config-M1L4xn8c.js";import{t as fe}from"./form-actions-CZxcWXSm.js";import{t as pe}from"./config-hints-CaB3I7KP.js";import{a as me,c as he,i as ge,l as _e,n as ve,o as ye,r as be,s as xe}from"./config-split-page-BaHtm9OW.js";var Se=f(`CircleDotDashed`,[[`path`,{d:`M10.1 2.18a9.93 9.93 0 0 1 3.8 0`,key:`1qdqn0`}],[`path`,{d:`M17.6 3.71a9.95 9.95 0 0 1 2.69 2.7`,key:`1bq7p6`}],[`path`,{d:`M21.82 10.1a9.93 9.93 0 0 1 0 3.8`,key:`1rlaqf`}],[`path`,{d:`M20.29 17.6a9.95 9.95 0 0 1-2.7 2.69`,key:`1xk03u`}],[`path`,{d:`M13.9 21.82a9.94 9.94 0 0 1-3.8 0`,key:`l7re25`}],[`path`,{d:`M6.4 20.29a9.95 9.95 0 0 1-2.69-2.7`,key:`1v18p6`}],[`path`,{d:`M2.18 13.9a9.93 9.93 0 0 1 0-3.8`,key:`xdo6bj`}],[`path`,{d:`M3.71 6.4a9.95 9.95 0 0 1 2.7-2.69`,key:`1jjmaz`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),Ce=f(`EyeOff`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Y=e(d(),1),we={providerId:``,providerType:null,isBuiltInType:!1,isCustom:!0,enabled:!0,displayName:``,apiKeySet:!1,apiKeyMasked:void 0,apiBase:null,extraHeaders:null,wireApi:null,models:[],modelConfig:{}};function X(e){if(!e)return null;let t=Object.entries(e).map(([e,t])=>[e.trim(),t]).filter(([e])=>e.length>0);return t.length===0?null:Object.fromEntries(t)}function Te(e,t){let n=X(e),r=X(t);if(n===null&&r===null)return!0;if(!n||!r)return!1;let i=Object.entries(n).sort(([e],[t])=>e.localeCompare(t)),a=Object.entries(r).sort(([e],[t])=>e.localeCompare(t));return i.length===a.length?i.every(([e,t],n)=>e===a[n][0]&&t===a[n][1]):!1}function Z(e){if(!e||e.length===0)return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function Ee(e,t){let n=e.trim();if(!n||!t.trim())return n;let r=`${t.trim()}/`;return n.startsWith(r)?n.slice(r.length):n}function Q(e,t){let n=e.trim();if(!n)return``;for(let e of t){let t=e.trim();t&&(n=Ee(n,t))}return n.trim()}function De(e,t){return e.length===t.length?e.every((e,n)=>e===t[n]):!1}function Oe(e,t){return Z(t)}function ke(e,t){return Z(e).map(e=>{let n=e.trim();return!n||n.startsWith(`${t}/`)?n:`${t}/${n}`})}function Ae(e,t){let n=new Set(t.map(e=>e.trim()).filter(Boolean)),r={};for(let[t,i]of Object.entries(e)){if(!n.has(t))continue;let e={},a=N(i.thinking?.supported);if(a.length>0){let t=I(i.thinking?.default);e.thinking=t&&a.includes(t)?{supported:a,default:t}:{supported:a}}i.vision===!0&&(e.vision=!0),(e.thinking||e.vision===!0)&&(r[t]=e)}return r}function je(e,t,n){return{...L(e,n),...L(t,n)}}function Me(e,t){let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i+=1){let a=n[i];if(a!==r[i])return!1;let o=e[a],s=t[a];if(!o||!s||!De([...o.thinking?.supported??[]].sort(),[...s.thinking?.supported??[]].sort())||(o.thinking?.default??null)!==(s.thinking?.default??null)||(o.vision??!1)!==(s.vision??!1))return!1}return!0}function Ne(e){return e.providerName?e.apiKey.trim().length>0||e.apiBase.trim()!==e.currentApiBase.trim()||!Te(e.extraHeaders,e.currentHeaders)||e.supportsWireApi&&e.wireApi!==e.currentWireApi||!De(e.models,e.currentEditableModels)||!Me(e.modelConfig,e.currentModelConfig)||e.providerDisplayName.trim()!==e.effectiveDisplayName:!1}function Pe(e){let t={},n=e.apiKey.trim(),r=e.apiBase.trim(),i=X(e.extraHeaders),a=e.providerDisplayName.trim();return a!==e.effectiveDisplayName&&(t.displayName=a.length>0?a:null),n.length>0&&(t.apiKey=n),r!==e.currentApiBase.trim()&&(t.apiBase=r.length>0&&r!==e.defaultApiBase?r:null),Te(i,e.currentHeaders)||(t.extraHeaders=i),e.supportsWireApi&&e.wireApi!==e.currentWireApi&&(t.wireApi=e.wireApi),De(e.models,e.currentEditableModels)||(t.models=ke(e.models,e.providerName??``)),Me(e.modelConfig,e.currentModelConfig)||(t.modelConfig=Ae(e.modelConfig,e.models)),t}function Fe(e){let t=Q(e.models.find(e=>e.trim().length>0)??``,e.providerModelAliases),n={...Ie(e),model:t||null};return e.supportsWireApi&&(n.wireApi=e.wireApi),n}function Ie(e){let t={apiBase:e.apiBase.trim(),extraHeaders:X(e.extraHeaders)};return e.apiKey.trim().length>0&&(t.apiKey=e.apiKey.trim()),t}function Le(e){return j(e===`off`?`chatThinkingLevelOff`:e===`minimal`?`chatThinkingLevelMinimal`:e===`low`?`chatThinkingLevelLow`:e===`medium`?`chatThinkingLevelMedium`:e===`high`?`chatThinkingLevelHigh`:e===`adaptive`?`chatThinkingLevelAdaptive`:`chatThinkingLevelXhigh`)}function Re(e){let{providerName:t,methods:n,defaultMethodId:r,language:i}=e;if(n.length===0)return``;let a=new Map;for(let e of n){let t=e.id.trim();t&&a.set(t.toLowerCase(),t)}let o=(...e)=>{for(let t of e){let e=a.get(t.toLowerCase());if(e)return e}},s=r?.trim();if(t===`minimax-portal`){if(i===`zh`)return o(`cn`,`china-mainland`)??o(s??``)??n[0]?.id??``;if(i===`en`)return o(`global`,`intl`,`international`)??o(s??``)??n[0]?.id??``}if(s){let e=o(s);if(e)return e}return i===`zh`?o(`cn`)??n[0]?.id??``:i===`en`?o(`global`)??n[0]?.id??``:n[0]?.id??``}function ze(e){let{required:t,hasDefault:n,optionCount:r}=e;return t&&n&&r>1&&r<=3}function Be(e,t,n){let r=Q(t,n);return r?e.includes(r)?{models:e,draft:``}:{models:[...e,r],draft:``}:{models:e,draft:t}}function Ve(e,t,n){let r=[...e],i=new Set(e);for(let e of t){let t=Q(e,n);t&&!i.has(t)&&(i.add(t),r.push(t))}return{models:r,addedCount:r.length-e.length}}function He(e,t,n){return Ve(e,t,n).models.slice(e.length)}function Ue(e,t,n){let r={...t};return delete r[n],{models:e.filter(e=>e!==n),modelConfig:r}}function We(e,t,n){let r=e[t],i=r?.thinking?.supported??[],a=i.includes(n)?i.filter(e=>e!==n):z.filter(e=>e===n||i.includes(e)),o=r?.thinking?.default&&a.includes(r.thinking.default)?r.thinking.default:void 0,s={...r,thinking:a.length>0?o?{supported:a,default:o}:{supported:a}:void 0},c={...e};return s.thinking||s.vision===!0?c[t]=s:delete c[t],c}function Ge(e,t,n){let r=e[t],i=r?.thinking;return!i||i.supported.length===0||n&&!i.supported.includes(n)?e:{...e,[t]:{...r,thinking:n?{supported:i.supported,default:n}:{supported:i.supported}}}}function Ke(e,t,n){let r={...e[t],vision:n?!0:void 0},i={...e};return r.thinking||r.vision===!0?i[t]=r:delete i[t],i}function qe(e){let{providerName:t,providerSpec:n,language:r}=e,i=n?.auth,a=i?.methods??[];return{providerAuth:i,providerAuthMethodOptions:a.map(e=>({value:e.id,label:e.label?.[r]||e.label?.en||e.id})),providerAuthMethods:a,preferredAuthMethodId:Re({providerName:n?.providerType??t,methods:a,defaultMethodId:i?.defaultMethodId,language:r}),shouldUseAuthMethodPills:ze({required:i?.kind===`device_code`,hasDefault:!!i?.defaultMethodId?.trim(),optionCount:a.length})}}function Je(e,t){let n=!!e?.supportsWireApi||t,r=(e?.wireApiOptions||[`auto`,`chat`,`responses`]).map(e=>({value:e,label:j(e===`chat`?`wireApiChat`:e===`responses`?`wireApiResponses`:`wireApiAuto`)}));return{shouldUseWireApiPills:ze({required:n,hasDefault:typeof e?.defaultWireApi==`string`&&e.defaultWireApi.length>0,optionCount:r.length}),supportsWireApi:n,wireApiSelectOptions:r}}function Ye(e){let{providerName:t,providersView:n,templatesView:r,schema:i,language:a}=e,o=t?n?.providers[t]:null,s=r?.providerTemplates.find(e=>e.providerType===o?.providerType),c=o??we,l=i?.uiHints,u=!!o?.isCustom,d=t?pe(`providers.${t}.apiKey`,l):void 0,f=t?pe(`providers.${t}.apiBase`,l):void 0,p=t?pe(`providers.${t}.extraHeaders`,l):void 0,m=t?pe(`providers.${t}.wireApi`,l):void 0,h=s?.displayName||o?.displayName||t||``,g=(c.displayName||``).trim()||h,_=c.enabled!==!1,v=u||s?.supportsModelDiscovery===!0,y=Z([s?.modelPrefix||s?.providerType||``,t||``]),b=s?.defaultApiBase||``,x=c.apiBase||b,S=X(c.extraHeaders||null),C=c.wireApi||s?.defaultWireApi||`auto`,w=Oe(Z((s?.defaultModels??[]).map(e=>Q(e,y))),Z((c.models??[]).map(e=>Q(e,y)))),T=Ae(je(s?.modelConfig,c.modelConfig,y),w),E=s?.apiBaseHelp?.[a]||s?.apiBaseHelp?.en||f?.help||j(`providerApiBaseHelp`),D=qe({providerName:t,providerSpec:s,language:a}),O=Je(s,u);return{apiBaseHelpText:E,apiBaseHint:f,apiKeyHint:d,currentApiBase:x,currentEditableModels:w,currentEnabled:_,currentHeaders:S,currentModelConfig:T,currentWireApi:C,defaultApiBase:b,defaultDisplayName:h,effectiveDisplayName:g,extraHeadersHint:p,...D,providerConfig:o,providerModelAliases:y,resolvedProviderConfig:c,supportsModelDiscovery:v,wireApiHint:m,...O}}function Xe(e){let{providerName:t,providerAuth:n,resolvedAuthMethodId:r}=e,a=l(),o=se(),s=oe(),c=te(),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),g=(0,Y.useRef)(null),_=(0,Y.useCallback)(()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),v=(0,Y.useCallback)((e,n)=>{_(),g.current=window.setTimeout(()=>{(async()=>{if(t)try{let r=await s.mutateAsync({provider:t,data:{sessionId:e}});if(r.status===`pending`){h(j(`providerAuthWaitingBrowser`)),v(e,r.nextPollMs??n);return}if(r.status===`authorized`){p(null),_(),h(j(`providerAuthCompleted`)),i.success(j(`providerAuthCompleted`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]});return}p(null),_(),h(r.message||`Authorization ${r.status}.`),i.error(r.message||`Authorization ${r.status}.`)}catch(e){p(null),_();let t=e instanceof Error?e.message:String(e);h(t),i.error(`Authorization failed: ${t}`)}})()},Math.max(1e3,n))},[_,s,t,a]),y=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),h(``);let e=await o.mutateAsync({provider:t,data:r?{methodId:r}:{}});if(!e.sessionId||!e.verificationUri)throw Error(j(`providerAuthStartFailed`));p(e.sessionId),h(`${j(`providerAuthOpenPrompt`)}${e.userCode}${j(`providerAuthOpenPromptSuffix`)}`),await ee.openExternalUrl(e.verificationUri),v(e.sessionId,e.intervalMs)}catch(e){let t=e instanceof Error?e.message:String(e);p(null),_(),h(t),i.error(`${j(`providerAuthStartFailed`)}: ${t}`)}},[_,n?.kind,t,r,v,o]),b=(0,Y.useCallback)(async()=>{if(!(!t||n?.kind!==`device_code`))try{d(t),_(),p(null);let e=await c.mutateAsync({provider:t});h(`${j(`providerAuthImportStatusPrefix`)}${e.expiresAt?` (expires: ${e.expiresAt})`:``}`),i.success(j(`providerAuthImportSuccess`)),a.invalidateQueries({queryKey:[`config`]}),a.invalidateQueries({queryKey:[`providers`]})}catch(e){let t=e instanceof Error?e.message:String(e);h(t),i.error(`${j(`providerAuthImportFailed`)}: ${t}`)}},[_,c,n?.kind,t,a]);return(0,Y.useEffect)(()=>{_()},[_,t]),(0,Y.useEffect)(()=>()=>_(),[_]),{authSessionId:u===t?f:null,authStatusMessage:u===t?m:``,importAuthFromCli:b,importPending:c.isPending,startAuth:y,startPending:o.isPending}}function Ze(e){let{providerName:t,apiKey:n,apiKeyRequired:r,apiKeySet:a,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:d,providerModelAliases:f}=e,p=ie(),m=ce(),h=(0,Y.useMemo)(()=>JSON.stringify({providerName:t,apiKey:n,apiBase:o,extraHeaders:s}),[o,n,s,t]),[g,_]=(0,Y.useState)(null),v=(0,Y.useCallback)(async()=>{if(t)try{let e=await p.mutateAsync({provider:t,data:Fe({apiKey:n,apiBase:o,extraHeaders:s,supportsWireApi:l,wireApi:u,models:d,providerModelAliases:f})});if(e.success){i.success(`${j(`providerTestConnectionSuccess`)} (${e.latencyMs}ms)`);return}let r=[`provider=${e.provider}`,`latency=${e.latencyMs}ms`];e.model&&r.push(`model=${e.model}`),i.error(`${j(`providerTestConnectionFailed`)}: ${e.message} | ${r.join(` | `)}`)}catch(e){let t=e instanceof Error?e.message:String(e);i.error(`${j(`providerTestConnectionFailed`)}: ${t}`)}},[o,n,s,d,f,t,l,p,u]);return{discoverModels:(0,Y.useCallback)(async()=>{if(!t)return null;if(r&&!n.trim()&&!a)return i.error(j(`providerModelsApiKeyRequired`)),null;try{let e=await m.mutateAsync({provider:t,data:Ie({apiKey:n,apiBase:o,extraHeaders:s})});return _({key:h,models:e.models}),i.success(j(`providerModelsFetchSuccess`)),e.models}catch(e){if(e instanceof c&&(e.details?.upstreamStatus===401||e.details?.upstreamStatus===403))return i.error(j(`providerModelsAuthorizationFailed`)),null;let t=e instanceof Error?e.message:String(e);return i.error(`${j(`providerModelsFetchFailed`)}: ${t}`),null}},[o,n,r,a,m,h,s,t]),fetchedModels:g?.key===h?g.models:[],isDiscoveringModels:m.isPending,isTestPending:p.isPending,testConnection:v}}var $=u();function Qe({value:e,onChange:n,className:r}){let i=e?Object.entries(e):[],o=(e,t,r)=>{let a=[...i];a[e]=[t,r],n(Object.fromEntries(a))},c=()=>{n({...e,"":``})},l=e=>{let t=i.filter((t,n)=>n!==e);n(Object.fromEntries(t))};return(0,$.jsxs)(`div`,{className:s(`space-y-2`,r),children:[i.map(([e,n],r)=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(t,{type:`text`,value:e,onChange:e=>o(r,e.target.value,n),placeholder:j(`headerName`),className:`flex-1`}),(0,$.jsx)(t,{type:`text`,value:n,onChange:t=>o(r,e,t.target.value),placeholder:j(`headerValue`),className:`flex-1`}),(0,$.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>l(r),children:(0,$.jsx)(k,{className:`h-4 w-4 text-red-500`})})]},r)),(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),j(`add`)]})]})}function $e(e){let{value:t,onChange:n,options:r}=e;return(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.map(e=>{let r=e.value===t;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":r,className:`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors ${r?`border-[var(--interaction-selection-border)] bg-[var(--interaction-selection)] text-foreground`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-[var(--interaction-hover)] hover:text-foreground`}`,children:e.label},e.value)})})}function et(e){let{showAdvanced:t,onShowAdvancedChange:n,supportsWireApi:i,wireApiLabel:a,wireApi:o,onWireApiChange:s,shouldUseWireApiPills:c,wireApiSelectOptions:l,extraHeadersLabel:u,extraHeaders:d,onExtraHeadersChange:f}=e;return(0,$.jsxs)(`div`,{className:`border-t border-border/70 pt-4`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(!t),className:`flex w-full items-center justify-between text-sm text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(O,{className:`h-3.5 w-3.5`}),j(`providerAdvancedSettings`)]}),(0,$.jsx)(b,{className:`h-4 w-4 transition-transform ${t?`rotate-180`:``}`})]}),t?(0,$.jsxs)(`div`,{className:`mt-4 space-y-5`,children:[i?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`wireApi`,className:`text-sm font-medium text-foreground`,children:a}),c?(0,$.jsx)($e,{value:o,onChange:e=>s(e),options:l}):(0,$.jsxs)(q,{value:o,onValueChange:e=>s(e),children:[(0,$.jsx)(W,{className:`rounded-xl`,children:(0,$.jsx)(U,{})}),(0,$.jsx)(G,{children:l.map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))})]})]}):null,(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:u}),(0,$.jsx)(Qe,{value:d,onChange:f}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerExtraHeadersHelpShort`)})]})]}):null]})}function tt({isSet:e,className:n,value:r,onChange:i,placeholder:o,...c}){let[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=typeof r==`string`&&r.length>0;return(0,$.jsxs)(`div`,{className:`relative`,children:[e&&!p&&!d?(0,$.jsx)(`div`,{onClick:()=>f(!0),className:s(`flex h-9 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2 text-sm text-gray-500 cursor-text items-center pr-12`,n),children:`••••••••••••`}):(0,$.jsx)(t,{type:l?`text`:`password`,className:s(`pr-12`,n),value:r,onChange:i,onBlur:()=>{p||f(!1)},placeholder:o,autoFocus:d,...c}),(0,$.jsx)(`div`,{className:`absolute right-2 top-1/2 -translate-y-1/2 flex gap-1`,children:(e||p)&&(0,$.jsx)(a,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>u(!l),children:l?(0,$.jsx)(Ce,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})})]})}function nt(e){let{apiKey:t,apiKeyRequired:n,apiKeySet:i,apiKeyPlaceholder:o,providerAuth:s,providerAuthNote:c,providerAuthMethodOptions:l,providerAuthMethodsCount:u,selectedAuthMethodHint:d,shouldUseAuthMethodPills:f,resolvedAuthMethodId:p,onAuthMethodChange:m,onStartProviderAuth:h,onImportProviderAuthFromCli:g,startPending:_,importPending:v,authSessionId:y,authStatusMessage:b,onApiKeyChange:x}=e,S=n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`apiKey`,className:`text-sm font-medium text-foreground`,children:j(`apiKey`)}),(0,$.jsx)(tt,{id:`apiKey`,value:t,isSet:i,onChange:e=>x(e.target.value),placeholder:o,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`leaveBlankToKeepUnchanged`)})]}):null;return s?.kind===`device_code`?(0,$.jsxs)($.Fragment,{children:[S,(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-muted/45 p-3`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:s.displayName||j(`providerAuthSectionTitle`)}),c?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c}):null,u>1?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{className:`text-xs font-medium text-foreground`,children:j(`providerAuthMethodLabel`)}),f?(0,$.jsx)($e,{value:p,onChange:m,options:l}):(0,$.jsxs)(q,{value:p,onValueChange:m,children:[(0,$.jsx)(W,{className:`h-8 rounded-lg`,children:(0,$.jsx)(U,{placeholder:j(`providerAuthMethodPlaceholder`)})}),(0,$.jsx)(G,{children:l.map(e=>(0,$.jsx)(K,{value:e.value,children:e.label},e.value))})]}),d?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d}):null]}):null,(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:h,disabled:_||!!y,children:j(_?`providerAuthStarting`:y?`providerAuthAuthorizing`:`providerAuthAuthorizeInBrowser`)}),s.supportsCliImport?(0,$.jsx)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:g,disabled:v,children:j(v?`providerAuthImporting`:`providerAuthImportFromCli`)}):null,y?(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[j(`providerAuthSessionLabel`),`: `,y.slice(0,8),`…`]}):null]}),b?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b}):null]})]}):S}function rt(e){let{providerName:t,models:n,aliases:r,fetchedModels:i=[],onModelsChange:a}=e,o=ne({pollWhileRefreshing:!0,refreshOnMount:!0}),s=t?o.data?.providers[t]:void 0,c=i.length>0?`fetched`:`background`,l=(0,Y.useMemo)(()=>He(n,c===`fetched`?i:s?.models??[],r),[r,s?.models,i,n,c]);return{addSuggestedModels:(0,Y.useCallback)(e=>{let t=Ve(n,e,r);t.addedCount>0&&a(t.models)},[r,n,a]),hasSuggestionError:!!(s?.lastError&&!s.fetchedAt),isCheckingSuggestions:!!(t&&(o.isLoading||o.data?.refreshing&&!s)),suggestedModels:l,suggestionSource:c}}function it(e){let{models:t,modelConfig:i,onModelsChange:a,onRemoveModel:o,onToggleModelThinkingLevel:s,onSetModelThinkingDefault:c,onSetModelVision:l,thinkingLevels:u,formatThinkingLevelLabel:d}=e,[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(()=>new Set),g=(0,Y.useMemo)(()=>t.filter(e=>m.has(e)),[t,m]),_=e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=()=>{p(!1),h(new Set)};return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`flex min-h-7 flex-wrap items-center justify-end gap-2`,children:f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`mr-auto text-xs text-muted-foreground`,children:j(`providerModelsSuggestionsSelected`).replace(`{count}`,String(g.length))}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-primary hover:text-primary/80`,onClick:()=>h(g.length===t.length?new Set:new Set(t)),children:j(g.length===t.length?`providerModelsClearSelection`:`providerModelsSelectAll`)}),(0,$.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:v,children:j(`cancel`)}),(0,$.jsxs)(`button`,{type:`button`,disabled:g.length===0,className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-xs font-medium text-destructive transition-colors hover:bg-destructive/15 disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>{g.length!==0&&(a(t.filter(e=>!m.has(e))),v())},children:[(0,$.jsx)(k,{className:`h-3 w-3`}),j(`providerModelsRemoveSelected`)]})]}):(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground`,onClick:()=>p(!0),children:[(0,$.jsx)(k,{className:`h-3 w-3`}),j(`providerModelsBulkRemove`)]})}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>{if(f)return(0,$.jsxs)(`label`,{className:`inline-flex max-w-full cursor-pointer items-center gap-2 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5 hover:bg-[var(--interaction-hover)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:m.has(e),onChange:()=>_(e),"aria-label":j(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e})]},e);let t=i[e],a=t?.thinking,p=a?.supported??[],h=a?.default??null,g=t?.vision===!0;return(0,$.jsxs)(`div`,{className:`group inline-flex max-w-full items-center gap-1 rounded-full border border-border/55 bg-muted/45 px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`max-w-[140px] truncate text-sm text-foreground sm:max-w-[220px]`,children:e}),(0,$.jsxs)(R,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-[var(--interaction-hover)] hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":j(`providerModelThinkingTitle`),title:j(`providerModelThinkingTitle`),children:(0,$.jsx)(O,{className:`h-3 w-3`})})}),(0,$.jsxs)(F,{className:`w-80 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-muted/50 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:j(`providerModelVisionTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelVisionHint`)})]}),(0,$.jsx)(n,{checked:g,onCheckedChange:t=>l(e,t)})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:j(`providerModelThinkingTitle`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelThinkingHint`)})]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>s(e,t),className:`rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${p.includes(t)?`border-[var(--interaction-selection-border)] bg-[var(--interaction-selection)] text-foreground`:`border-border/55 bg-muted/50 text-muted-foreground hover:border-border hover:bg-[var(--interaction-hover)] hover:text-foreground`}`,children:d(t)},t))}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(r,{className:`text-xs font-medium text-foreground`,children:j(`providerModelThinkingDefault`)}),(0,$.jsxs)(q,{value:h??`__none__`,onValueChange:t=>c(e,t===`__none__`?null:t),disabled:p.length===0,children:[(0,$.jsx)(W,{className:`h-8 rounded-lg text-xs`,children:(0,$.jsx)(U,{})}),(0,$.jsxs)(G,{children:[(0,$.jsx)(K,{value:`__none__`,children:j(`providerModelThinkingDefaultNone`)}),p.map(e=>(0,$.jsx)(K,{value:e,children:d(e)},e))]})]}),p.length===0?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelThinkingNoSupported`)}):null]})]})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e),className:`inline-flex h-5 w-5 items-center justify-center rounded-full text-muted-foreground/70 opacity-100 transition-opacity hover:bg-[var(--interaction-hover)] hover:text-foreground md:opacity-0 md:group-hover:opacity-100 md:group-focus-within:opacity-100`,"aria-label":j(`remove`),children:(0,$.jsx)(C,{className:`h-3 w-3`})})]},e)})}),f?(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerModelsRemoveSaveHint`)}):null]})}var at=20,ot=50,st=50;function ct(e){let{expanded:n,fetchedTotal:r,models:i,source:a,onExpandedChange:o,onAddModels:s}=e,[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(()=>new Set),f=(0,Y.useMemo)(()=>{let e=c.trim().toLowerCase();return e?i.filter(t=>t.toLowerCase().includes(e)):i},[i,c]),p=f.slice(0,st),m=(0,Y.useMemo)(()=>i.filter(e=>u.has(e)),[i,u]),g=e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=e=>{e.length!==0&&(s(e),l(``),d(new Set))},b=a===`fetched`?`providerModelsFetchedSuggestionsSummary`:`providerModelsSuggestionsSummary`;return a===`fetched`&&i.length===0?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,role:`status`,children:[(0,$.jsx)(_,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{children:j(`providerModelsFetchedAllConfigured`).replace(`{count}`,String(r))})]}):(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":n,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-2 py-1.5 text-left text-xs text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground`,onClick:()=>o(!n),children:[(0,$.jsx)(_,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:j(b).replace(`{count}`,String(i.length))}),(0,$.jsx)(h,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${n?`rotate-90`:``}`})]}),i.length<=ot?(0,$.jsx)(`button`,{type:`button`,className:`shrink-0 rounded-lg px-2 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-[var(--interaction-hover)]`,onClick:()=>v(i),children:j(`providerModelsSuggestionsAddAll`)}):null]}),n?(0,$.jsxs)(`div`,{className:`px-1 pb-1`,children:[i.length>at?(0,$.jsxs)(`div`,{className:`relative px-2 pb-1 pt-1.5`,children:[(0,$.jsx)(y,{className:`pointer-events-none absolute left-4 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(t,{value:c,onChange:e=>l(e.target.value),placeholder:j(`providerModelsSuggestionsSearchPlaceholder`),className:`h-8 rounded-lg pl-8 text-xs`})]}):null,(0,$.jsxs)(`div`,{className:`custom-scrollbar max-h-44 overflow-y-auto`,children:[p.map(e=>(0,$.jsxs)(`label`,{className:`grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)] items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-[var(--interaction-hover)]`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:u.has(e),onChange:()=>g(e),"aria-label":j(`providerModelsSuggestionSelect`).replace(`{model}`,e),className:`h-3.5 w-3.5 shrink-0 accent-primary`}),(0,$.jsx)(`span`,{className:`block min-w-0 truncate text-xs text-foreground`,title:e,children:e})]},e)),f.length===0?(0,$.jsx)(`p`,{className:`px-2 py-4 text-center text-xs text-muted-foreground`,children:j(`providerModelsSuggestionsSearchEmpty`)}):null]}),f.length>p.length?(0,$.jsx)(`p`,{className:`px-2 pt-1 text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsShowing`).replace(`{visible}`,String(p.length)).replace(`{count}`,String(f.length))}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-2 pt-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsSelected`).replace(`{count}`,String(m.length))}),(0,$.jsx)(`button`,{type:`button`,disabled:m.length===0,className:`shrink-0 rounded-md bg-primary/10 px-2 py-1 text-[11px] font-medium text-primary transition-colors hover:bg-[var(--interaction-hover)] disabled:cursor-not-allowed disabled:opacity-45`,onClick:()=>v(m),children:j(`providerModelsSuggestionsAddSelected`)})]}),(0,$.jsx)(`p`,{className:`px-2 pb-1 pt-1 text-[11px] text-muted-foreground`,children:j(`providerModelsSuggestionsSaveHint`)})]}):null]})}function lt({hasFetchedCatalog:e,hasSuggestionError:t,supportsModelDiscovery:n}){return!n||!t||e?null:(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,$.jsx)(g,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),j(`providerModelsSuggestionsFailed`)]})}function ut(e){let{providerName:n,providerModelAliases:i,models:o,modelConfig:s,modelDraft:c,showModelInput:l,onModelDraftChange:u,onShowModelInputChange:d,onAddModel:f,onModelsChange:p,supportsModelDiscovery:m,onDiscoverModels:h,isDiscoveringModels:g,fetchedModels:_,onRemoveModel:v,onToggleModelThinkingLevel:y,onSetModelThinkingDefault:b,onSetModelVision:x,thinkingLevels:w,formatThinkingLevelLabel:T}=e,[O,k]=(0,Y.useState)(!1),A=(0,Y.useRef)(null),{addSuggestedModels:M,hasSuggestionError:N,isCheckingSuggestions:P,suggestedModels:F,suggestionSource:I}=rt({providerName:n,models:o,aliases:i,fetchedModels:_,onModelsChange:p}),L=async()=>{await h()&&(k(!0),window.requestAnimationFrame(()=>{let e=A.current;e?.scrollIntoView?.({behavior:`smooth`,block:`center`}),e?.focus({preventScroll:!0})}))},R=_.length>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(r,{className:`text-sm font-medium text-foreground`,children:j(`providerModelsTitle`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[m?(0,$.jsxs)(`button`,{type:`button`,onClick:L,disabled:g,className:`flex items-center gap-1 text-xs font-medium text-primary transition-colors hover:text-primary/80 disabled:cursor-wait disabled:opacity-60`,children:[(0,$.jsx)(D,{className:`h-3 w-3 ${g?`animate-spin`:``}`}),j(g?`providerModelsFetching`:`providerModelsFetch`)]}):null,l?null:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),className:`flex items-center gap-1 text-xs font-medium text-primary hover:text-primary/80`,children:[(0,$.jsx)(E,{className:`h-3 w-3`}),j(`providerAddModel`)]})]})]}),l?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(t,{value:c,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f()),e.key===`Escape`&&(d(!1),u(``))},placeholder:j(`providerModelInputPlaceholder`),className:`flex-1 rounded-xl`,autoFocus:!0}),(0,$.jsx)(a,{type:`button`,size:`sm`,onClick:f,disabled:c.trim().length===0,children:j(`add`)}),(0,$.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{d(!1),u(``)},children:(0,$.jsx)(C,{className:`h-4 w-4`})})]}):null,(0,$.jsx)(lt,{hasFetchedCatalog:R,hasSuggestionError:N,supportsModelDiscovery:m}),m&&P&&!R?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-xl bg-muted/35 px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(S,{className:`h-3.5 w-3.5 animate-spin`}),j(`providerModelsSuggestionsChecking`)]}):m&&(F.length>0||R)?(0,$.jsx)(`div`,{ref:A,tabIndex:-1,"aria-live":`polite`,className:`scroll-m-4 outline-none`,children:(0,$.jsx)(ct,{expanded:O,fetchedTotal:_.length,models:F,source:I,onExpandedChange:k,onAddModels:M})}):null,o.length===0?(0,$.jsxs)(`div`,{className:`rounded-xl bg-muted/35 px-4 py-6 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:j(`providerModelsEmptyShort`)}),l?null:(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:`mt-2 text-sm font-medium text-primary hover:text-primary/80`,children:j(`providerAddFirstModel`)})]}):(0,$.jsx)(it,{models:o,modelConfig:s,onModelsChange:p,onRemoveModel:v,onToggleModelThinkingLevel:y,onSetModelThinkingDefault:b,onSetModelVision:x,thinkingLevels:w,formatThinkingLevelLabel:T})]})}function dt({apiKeyRequired:e=!0,apiKeySet:t,className:n,enabled:r}){if(!r)return(0,$.jsx)(V,{status:`inactive`,label:j(`disabled`),className:n});let i=!e||t;return(0,$.jsx)(V,{status:i?`ready`:`setup`,label:j(i?`statusReady`:`statusSetup`),className:n})}function ft(e){let{context:n,language:i,providerTitle:o,providerDisplayName:s,apiKey:c,apiBase:l,extraHeaders:u,wireApi:d,models:f,modelConfig:p,modelDraft:m,showAdvanced:h,showModelInput:g,resolvedAuthMethodId:_,authSessionId:v,authStatusMessage:y,hasChanges:b,isDeletePending:x,isUpdatePending:S,connectivity:C,startPending:w,importPending:T,onProviderDisplayNameChange:E,onApiKeyChange:D,onApiBaseChange:O,onAuthMethodChange:A,onStartProviderAuth:M,onImportProviderAuthFromCli:N,onModelDraftChange:P,onShowModelInputChange:F,onAddModel:I,onModelsChange:L,onRemoveModel:R,onToggleModelThinkingLevel:B,onSetModelThinkingDefault:V,onSetModelVision:H,onShowAdvancedChange:ee,onWireApiChange:U,onExtraHeadersChange:W,onDeleteProvider:G,onSubmit:K,onTestConnection:q}=e,J=n.providerAuthMethods.find(e=>e.id===_);return(0,$.jsxs)(ve,{children:[(0,$.jsx)(he,{className:`px-5 py-4`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`truncate text-lg font-semibold text-foreground`,children:o}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:G,disabled:x,className:`text-muted-foreground/70 transition-colors hover:text-red-500`,title:j(`providerDelete`),children:(0,$.jsx)(k,{className:`h-4 w-4`})}),(0,$.jsx)(dt,{enabled:n.currentEnabled,apiKeyRequired:n.resolvedProviderConfig.apiKeyRequired,apiKeySet:n.resolvedProviderConfig.apiKeySet})]})]})}),(0,$.jsxs)(`form`,{onSubmit:K,className:`flex min-h-0 flex-1 flex-col`,children:[(0,$.jsxs)(ye,{className:`space-y-4 px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`providerDisplayName`,className:`text-sm font-medium text-foreground`,children:j(`providerDisplayName`)}),(0,$.jsx)(t,{id:`providerDisplayName`,type:`text`,value:s,onChange:e=>E(e.target.value),placeholder:n.defaultDisplayName||j(`providerDisplayNamePlaceholder`),className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:j(`providerDisplayNameHelpShort`)})]}),(0,$.jsx)(nt,{apiKey:c,apiKeyRequired:n.resolvedProviderConfig.apiKeyRequired!==!1,apiKeySet:n.resolvedProviderConfig.apiKeySet,apiKeyPlaceholder:n.apiKeyHint?.placeholder??j(`enterApiKey`),providerAuth:n.providerAuth,providerAuthNote:n.providerAuth?.note?.[i]||n.providerAuth?.note?.en||n.providerAuth?.displayName||``,providerAuthMethodOptions:n.providerAuthMethodOptions,providerAuthMethodsCount:n.providerAuthMethods.length,selectedAuthMethodHint:J?.hint?.[i]||J?.hint?.en||``,shouldUseAuthMethodPills:n.shouldUseAuthMethodPills,resolvedAuthMethodId:_,onAuthMethodChange:A,onStartProviderAuth:M,onImportProviderAuthFromCli:N,startPending:w,importPending:T,authSessionId:v,authStatusMessage:y,onApiKeyChange:D}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(r,{htmlFor:`apiBase`,className:`text-sm font-medium text-foreground`,children:j(`apiBase`)}),(0,$.jsx)(t,{id:`apiBase`,type:`text`,value:l,onChange:e=>O(e.target.value),placeholder:n.defaultApiBase||n.apiBaseHint?.placeholder||`https://api.example.com`,className:`rounded-xl`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n.apiBaseHelpText})]}),(0,$.jsx)(ut,{providerName:n.providerConfig?.providerId??``,providerModelAliases:n.providerModelAliases,models:f,modelConfig:p,modelDraft:m,showModelInput:g,onModelDraftChange:P,onShowModelInputChange:F,onAddModel:I,onModelsChange:L,supportsModelDiscovery:n.supportsModelDiscovery,onDiscoverModels:C.discoverModels,isDiscoveringModels:C.isDiscoveringModels,fetchedModels:C.fetchedModels,onRemoveModel:R,onToggleModelThinkingLevel:B,onSetModelThinkingDefault:V,onSetModelVision:H,thinkingLevels:z,formatThinkingLevelLabel:Le},n.providerConfig?.providerId),(0,$.jsx)(et,{showAdvanced:h,onShowAdvancedChange:ee,supportsWireApi:n.supportsWireApi,wireApiLabel:j(`wireApi`),wireApi:d,onWireApiChange:U,shouldUseWireApiPills:n.shouldUseWireApiPills,wireApiSelectOptions:n.wireApiSelectOptions,extraHeadersLabel:j(`extraHeaders`),extraHeaders:u,onExtraHeadersChange:W})]}),(0,$.jsx)(xe,{children:(0,$.jsxs)(fe,{align:`between`,children:[(0,$.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:q,disabled:C.isTestPending,children:[(0,$.jsx)(Se,{className:`mr-1.5 h-3.5 w-3.5`}),C.isTestPending?j(`providerTestingConnection`):j(`providerTestConnection`)]}),(0,$.jsx)(a,{type:`submit`,size:`sm`,disabled:S||!b,children:j(S?`saving`:b?`save`:`unchanged`)})]})})]})]})}function pt({providerName:e,onProviderDeleted:t}){let{data:n}=le(),{data:r}=re(),{data:i}=ue(),a=A(),o=(0,Y.useMemo)(()=>Ye({providerName:e,providersView:n,templatesView:r,schema:i,language:a}),[a,e,n,i,r]);if(!e||!o.providerConfig)return(0,$.jsx)(be,{children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:j(`providersSelectTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:j(`providersSelectDescription`)})]})});let s=JSON.stringify({providerConfig:o.providerConfig,currentApiBase:o.currentApiBase,currentEditableModels:o.currentEditableModels,currentModelConfig:o.currentModelConfig,currentWireApi:o.currentWireApi,effectiveDisplayName:o.effectiveDisplayName,preferredAuthMethodId:o.preferredAuthMethodId});return(0,$.jsx)(mt,{providerName:e,onProviderDeleted:t,context:o,language:a},s)}function mt({providerName:e,onProviderDeleted:t,context:n,language:r}){let i=de(),a=J(),{currentApiBase:o,currentEditableModels:s,currentHeaders:c,currentModelConfig:l,currentWireApi:u,defaultApiBase:d,effectiveDisplayName:f,providerAuth:p,providerAuthMethods:m,providerModelAliases:h,resolvedProviderConfig:g,preferredAuthMethodId:_,supportsWireApi:v}=n,[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(o),[C,w]=(0,Y.useState)(g.extraHeaders||null),[T,E]=(0,Y.useState)(u),[D,O]=(0,Y.useState)(s),[k,A]=(0,Y.useState)(l),[M,N]=(0,Y.useState)(``),[P,F]=(0,Y.useState)(f),[I,L]=(0,Y.useState)(!1),[R,z]=(0,Y.useState)(!1),[B,V]=(0,Y.useState)(_),H=Ze({providerName:e,apiKey:y,apiKeyRequired:g.apiKeyRequired!==!1,apiKeySet:g.apiKeySet,apiBase:x,extraHeaders:C,supportsWireApi:v,wireApi:T,models:D,providerModelAliases:h}),ee=P.trim()||f||e||j(`providersSelectPlaceholder`),U=(0,Y.useMemo)(()=>{if(!m.length)return``;let e=B.trim();return e&&m.some(t=>t.id===e)?e:_||m[0]?.id||``},[B,_,m]),{authSessionId:W,authStatusMessage:G,importAuthFromCli:K,importPending:q,startAuth:te,startPending:ne}=Xe({providerName:e,providerAuth:p,resolvedAuthMethodId:U}),re=(0,Y.useMemo)(()=>Ne({providerName:e,apiKey:y,apiBase:x,currentApiBase:o,extraHeaders:C,currentHeaders:c,supportsWireApi:v,wireApi:T,currentWireApi:u,models:D,currentEditableModels:s,modelConfig:k,currentModelConfig:l,providerDisplayName:P,effectiveDisplayName:f}),[e,y,x,o,C,c,v,T,u,D,s,k,l,P,f]),ie=e=>{O(e),A(t=>Ae(t,e))};return(0,$.jsx)(ft,{context:n,language:r,providerTitle:ee,providerDisplayName:P,apiKey:y,apiBase:x,extraHeaders:C,wireApi:T,models:D,modelConfig:k,modelDraft:M,showAdvanced:I,showModelInput:R,resolvedAuthMethodId:U,authSessionId:W,authStatusMessage:G,hasChanges:re,isDeletePending:a.isPending,isUpdatePending:i.isPending,connectivity:H,startPending:ne,importPending:q,onProviderDisplayNameChange:F,onApiKeyChange:b,onApiBaseChange:S,onAuthMethodChange:V,onStartProviderAuth:te,onImportProviderAuthFromCli:K,onModelDraftChange:N,onShowModelInputChange:z,onAddModel:()=>{let e=Be(D,M,h);ie(e.models),N(e.draft)},onModelsChange:ie,onRemoveModel:e=>{let t=Ue(D,k,e);O(t.models),A(t.modelConfig)},onToggleModelThinkingLevel:(e,t)=>{A(n=>We(n,e,t))},onSetModelThinkingDefault:(e,t)=>{A(n=>Ge(n,e,t))},onSetModelVision:(e,t)=>{A(n=>Ke(n,e,t))},onShowAdvancedChange:L,onWireApiChange:E,onExtraHeadersChange:w,onDeleteProvider:async()=>{if(e&&window.confirm(j(`providerDeleteConfirm`)))try{await a.mutateAsync({provider:e}),t?.(e)}catch{}},onSubmit:t=>{t.preventDefault(),e&&i.mutate({provider:e,data:Pe({providerName:e,apiKey:y,apiBase:x,currentApiBase:o,defaultApiBase:d,extraHeaders:C,currentHeaders:c,supportsWireApi:v,wireApi:T,currentWireApi:u,models:D,currentEditableModels:s,modelConfig:k,currentModelConfig:l,providerDisplayName:P,effectiveDisplayName:f})})},onTestConnection:H.testConnection})}function ht(e){if(!e)return null;try{let t=new URL(e);return`${t.host}${t.pathname&&t.pathname!==`/`?t.pathname:``}`}catch{return e.replace(/^https?:\/\//,``)}}function gt(e,t=[]){let n=new Map(t.map((e,t)=>[e,t]));return e.map((e,t)=>({provider:e,index:t})).sort((e,t)=>{let r=n.get(e.provider.providerId),i=n.get(t.provider.providerId);if(r!==void 0||i!==void 0)return(r??2**53-1)-(i??2**53-1);let a=e.provider.providerType===`nextclaw`?1:0,o=t.provider.providerType===`nextclaw`?1:0;return a===o?e.index-t.index:a-o}).map(({provider:e})=>e)}function _t(e){let t=e.findIndex(e=>e.providerType===`zhipu`),n=e.findIndex(e=>e.providerType===`dashscope-coding-plan`);return e.map((e,t)=>({template:e,index:t})).sort((e,r)=>{let i=({template:e,index:r})=>e.providerType===`nextclaw`?2**53-1:e.providerType===`deepseek`&&n>=0?n-.5:e.providerType===`mimo`&&t>=0?t+.5:r;return i(e)-i(r)}).map(({template:e})=>e)}function vt(){let{isMobile:e}=T(),{data:r}=le(),{data:i}=re(),c=ae(),l=J(),u=de(),[d,f]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,b]=(0,Y.useState)(!1),[x,S]=(0,Y.useState)([]),[C,D]=(0,Y.useState)(``),O=(0,Y.useMemo)(()=>gt(Object.values(r?.providers??{}),x),[r?.providers,x]),A=(0,Y.useMemo)(()=>i?.providerTemplates??[],[i?.providerTemplates]),N=(0,Y.useMemo)(()=>_t(A),[A]),I=(0,Y.useMemo)(()=>new Map(A.map(e=>[e.providerType,e])),[A]),L=(0,Y.useMemo)(()=>{let e=C.trim().toLowerCase();return O.filter(t=>{if(!e)return!0;let n=t.providerType?I.get(t.providerType):null;return(t.displayName?.trim()||n?.displayName||t.providerId).toLowerCase().includes(e)||t.providerId.toLowerCase().includes(e)})},[O,C,I]),z=(0,Y.useMemo)(()=>d&&L.some(e=>e.providerId===d)?d:e?null:L[0]?.providerId??null,[L,e,d]);return!r||!i?(0,$.jsx)(o,{title:j(`providersPageTitle`),description:j(`providersPageDescription`),layout:`split`,children:(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:j(`providersLoading`)})}):(0,$.jsxs)(o,{title:j(`providersPageTitle`),description:j(`providersPageDescription`),layout:`split`,children:[(0,$.jsxs)(me,{className:`md:min-h-0`,compactView:d?`detail`:`list`,onMobileBack:()=>f(null),mobileListLabel:j(`providersPageTitle`),children:[(0,$.jsxs)(_e,{children:[(0,$.jsx)(he,{className:`space-y-3 px-4 pb-3 pt-4`,children:(0,$.jsxs)(R,{open:_,onOpenChange:b,children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsxs)(a,{type:`button`,variant:`outline`,className:`w-full justify-center`,disabled:c.isPending,children:[(0,$.jsx)(E,{className:`mr-2 h-4 w-4`}),c.isPending?j(`saving`):j(`providerAdd`)]})}),(0,$.jsxs)(F,{className:`w-[42rem] max-w-[calc(100vw-2rem)] p-3`,align:`start`,children:[(0,$.jsx)(`div`,{className:`mb-2 px-1 text-xs font-semibold text-muted-foreground`,children:j(`providerTemplatePickerTitle`)}),(0,$.jsxs)(`div`,{className:`grid max-h-[24rem] grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-dashed border-border/70 bg-muted/20 px-3 py-2 text-left transition-colors hover:border-border hover:bg-[var(--interaction-hover)]`,onClick:async()=>{try{let e=await c.mutateAsync({data:{providerType:null}});D(``),f(e.providerId),S(t=>[e.providerId,...t.filter(t=>t!==e.providerId)]),b(!1)}catch{}},children:[(0,$.jsx)(B,{name:`custom`,className:`h-8 w-8 rounded-lg border border-border/60 bg-muted/50`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:j(`providerAddCustom`)})]}),N.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-20 w-full flex-col items-start gap-2 rounded-lg border border-border/55 bg-muted/15 px-3 py-2 text-left transition-colors hover:border-border/80 hover:bg-[var(--interaction-hover)]`,onClick:async()=>{try{let t=await c.mutateAsync({data:{providerType:e.providerType}});D(``),f(t.providerId),S(e=>[t.providerId,...e.filter(e=>e!==t.providerId)]),b(!1)}catch{}},children:[(0,$.jsx)(B,{name:e.providerType,src:e.logo?`/logos/${e.logo}`:null,className:`h-8 w-8 rounded-lg border border-border/55 bg-background`,imgClassName:`h-4 w-4 object-contain`}),(0,$.jsx)(`span`,{className:`line-clamp-2 min-w-0 text-xs font-semibold leading-4 text-foreground`,children:e.displayName||e.providerType})]},e.providerType))]})]})]})}),(0,$.jsx)(`div`,{className:`border-b border-border/70 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(y,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground/70`}),(0,$.jsx)(t,{value:C,onChange:e=>D(e.target.value),placeholder:j(`providersFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,$.jsxs)(ye,{className:`space-y-2 p-3`,children:[L.map(e=>{let t=e.providerType?I.get(e.providerType):null,r=e.enabled!==!1,i=M(e),a=e.displayName?.trim()||t?.displayName||e.providerId,o=ht(e.apiBase||t?.defaultApiBase||``)||j(`providersDefaultDescription`);return(0,$.jsx)(`div`,{onClick:()=>f(e.providerId),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),f(e.providerId))},role:`button`,tabIndex:0,className:s(`group w-full rounded-xl p-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/40`,z===e.providerId?`bg-[var(--interaction-selection)] text-foreground`:`bg-transparent text-muted-foreground hover:bg-[var(--interaction-hover)] hover:text-foreground`),children:(0,$.jsxs)(`div`,{className:`relative min-h-10`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 pr-20`,children:[(0,$.jsx)(B,{name:e.providerType??e.providerId,src:t?.logo?`/logos/${t.logo}`:null,className:`h-10 w-10 rounded-lg bg-background/80`,imgClassName:`h-5 w-5 object-contain`,fallback:(0,$.jsx)(`span`,{className:`text-sm font-semibold uppercase text-muted-foreground`,children:e.providerId[0]})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:a}),(0,$.jsx)(`p`,{className:`truncate font-mono text-[10px] text-muted-foreground/65`,children:e.providerId}),(0,$.jsxs)(`p`,{className:`line-clamp-1 text-[11px] text-muted-foreground`,children:[o,` · `,e.models?.length??0]})]})]}),(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 flex items-center gap-1.5 opacity-70 transition-opacity group-hover:opacity-100`,children:[(0,$.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(n,{checked:r,disabled:u.isPending,title:j(r?`disabled`:`enabled`),className:`h-[18px] w-8`,thumbClassName:`h-4 w-4 data-[state=checked]:translate-x-4`,onCheckedChange:t=>{u.mutateAsync({provider:e.providerId,data:{enabled:t},silentSuccess:!0})}})}),(0,$.jsxs)(R,{children:[(0,$.jsx)(P,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-lg text-muted-foreground/70 hover:bg-[var(--interaction-hover)] hover:text-foreground`,onClick:e=>e.stopPropagation(),title:j(`more`),children:(0,$.jsx)(v,{className:`h-4 w-4`})})}),(0,$.jsx)(F,{variant:`menu`,align:`end`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(`button`,{type:`button`,className:`${p} ${m.destructive}`,onClick:()=>g(e.providerId),children:[(0,$.jsx)(k,{className:`h-4 w-4`}),j(`providerDelete`)]})})]})]}),(0,$.jsx)(V,{status:r?i?`ready`:`setup`:`inactive`,label:j(r?i?`statusReady`:`statusSetup`:`disabled`),className:`absolute bottom-0 right-0 justify-end`})]})},e.providerId)}),L.length===0?(0,$.jsx)(ge,{icon:w,title:j(`providersNoMatch`)}):null]})]}),(0,$.jsx)(pt,{providerName:z??void 0,onProviderDeleted:e=>{S(t=>t.filter(t=>t!==e)),e===z&&f(null)}})]}),(0,$.jsx)(H,{open:!!h,onOpenChange:e=>{e||g(null)},title:j(`providerDelete`),description:h??void 0,confirmLabel:j(`delete`),variant:`destructive`,onCancel:()=>g(null),onConfirm:()=>{h&&l.mutateAsync({provider:h}).then(()=>{S(e=>e.filter(e=>e!==h)),h===z&&f(null),g(null)})}})]})}export{vt as ProvidersConfigPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as e,O as t,T as n}from"./theme-provider-BsJ6HxeX.js";import{Jt as r,Xn as i,Yt as a,_n as o,fn as s,qt as c,ur as l}from"./api-CXWxExzS.js";import{t as u}from"./createLucideIcon-C3LSyx-e.js";import{t as d}from"./download-C2gYe8n1.js";import{t as f}from"./x-waP-WLuT.js";import{s as p}from"./i18n-ByVUrt9w.js";var m={"paper-ink":`#FAF8F4`,"plain-paper":`#FAF8F4`,natural:`#FAF9F7`,work:`#FFFFFF`,minimal:`#FFFFFF`,warm:`#FAF8F4`,cool:`#F8FAFC`,dawn:`#FAF7F4`,graphite:`#F8F8F7`,night:`#101318`,charcoal:`#1C1C1C`,island:`#FBF8ED`,probe:`#FEFCF6`},h=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let r=m[t(e)];this.updateThemeMeta(r),this.updateSurfaceBackgrounds(r);let i=n(e);document.documentElement.style.colorScheme=i,document.querySelector(`meta[name="color-scheme"]`)?.setAttribute(`content`,i)},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let t=document.documentElement.getAttribute(`data-theme`);this.syncTheme(e(t)??`default`)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},g=u(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),_=`nextclaw-pwa-install-banner-dismissed`,v=`nextclaw-pwa-install-banner-dismissed-until`;function y(){let e=S();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:C(e):!1}function b(){let e=S();e?.setItem(_,`1`),e?.removeItem(v)}function x(){let e=S();e?.removeItem(_),e?.removeItem(v)}function S(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function C(e){let t=e.getItem(v);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(v),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(_,`1`),!0)}function w(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:y()}}var T=s(()=>w()),E=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),T.setState(w())},this.refreshState=()=>{let e=this.resolveInstallability();T.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:y()}))},this.dismissInstallPrompt=()=>{b(),T.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(x(),this.refreshState(),i.success(p(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,x(),T.setState({dismissedInstallPrompt:!0}),i.success(p(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}},D=l();function O(){let e=T(e=>e.installability);return(0,D.jsx)(`span`,{className:o(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:k(e)})}function k(e){return p(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function A(e,t,n){return p(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function j(){let e=T(e=>e.installability),t=T(e=>e.installMethod),n=T(e=>e.blockedReason);return(0,D.jsx)(r,{title:p(`pwaInstallTitle`),description:p(`pwaInstallDescription`),actions:(0,D.jsx)(O,{}),children:(0,D.jsx)(c,{children:(0,D.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:A(e,t,n)}),e===`available`&&t===`prompt`?(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsxs)(a,{type:`button`,className:`gap-2`,onClick:()=>void E.promptInstall(),children:[(0,D.jsx)(d,{className:`h-4 w-4`}),p(`pwaInstallAction`)]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,D.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-background/65 p-4`,children:[(0,D.jsx)(g,{className:`mt-0.5 h-4 w-4 text-muted-foreground`}),(0,D.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:p(`pwaInstallManualHint`)})]}):null]})})})}function M(){let e=T(e=>e.installability),t=T(e=>e.installMethod),n=T(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,D.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:p(`pwaInstallBannerTitle`)}),(0,D.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:p(`pwaInstallBannerDescription`)})]}),(0,D.jsx)(`button`,{type:`button`,"aria-label":p(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-[var(--interaction-hover)] hover:text-gray-600`,onClick:()=>{E.dismissInstallPrompt()},children:(0,D.jsx)(f,{className:`h-4 w-4`})})]}),(0,D.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,D.jsxs)(a,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{E.promptInstall()},children:[(0,D.jsx)(d,{className:`h-4 w-4`}),p(`pwaInstallAction`)]}),(0,D.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{E.dismissInstallPrompt()},children:p(`pwaInstallDismiss`)})]})]})}var N=new class{constructor(){this.started=!1,this.registration=null,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{this.registration=await navigator.serviceWorker.register(`/sw.js`)}catch{return}}},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(this.started=!1,this.registration=null)},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));await Promise.all(e.map(async e=>await e.unregister())),e.length>0&&await this.clearNextClawCaches()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))}}},P=!1;function F(){P||typeof window>`u`||(P=!0,E.start(),N.start())}export{h as i,M as n,j as r,F as t};
|
|
1
|
+
import{D as e,O as t,T as n}from"./theme-provider-D4rd-tCP.js";import{Jt as r,Xn as i,Yt as a,_n as o,fn as s,qt as c,ur as l}from"./api-CXWxExzS.js";import{t as u}from"./createLucideIcon-C3LSyx-e.js";import{t as d}from"./download-C2gYe8n1.js";import{t as f}from"./x-waP-WLuT.js";import{s as p}from"./i18n-ByVUrt9w.js";var m={"paper-ink":`#FAF8F4`,"plain-paper":`#FAF8F4`,natural:`#FAF9F7`,work:`#FFFFFF`,minimal:`#FFFFFF`,warm:`#FAF8F4`,cool:`#F8FAFC`,dawn:`#FAF7F4`,graphite:`#F8F8F7`,night:`#101318`,charcoal:`#1C1C1C`,island:`#FBF8ED`,probe:`#FEFCF6`},h=new class{constructor(){this.syncTheme=e=>{if(typeof document>`u`)return;let r=m[t(e)];this.updateThemeMeta(r),this.updateSurfaceBackgrounds(r);let i=n(e);document.documentElement.style.colorScheme=i,document.querySelector(`meta[name="color-scheme"]`)?.setAttribute(`content`,i)},this.syncCurrentTheme=()=>{if(typeof document>`u`)return;let t=document.documentElement.getAttribute(`data-theme`);this.syncTheme(e(t)??`default`)},this.updateThemeMeta=e=>{let t=document.querySelector(`meta[name="theme-color"]`);t instanceof HTMLMetaElement&&(t.content=e)},this.updateSurfaceBackgrounds=e=>{document.documentElement.style.backgroundColor=e,document.body.style.backgroundColor=e;let t=document.getElementById(`root`);t&&(t.style.backgroundColor=e)}}},g=u(`Smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),_=`nextclaw-pwa-install-banner-dismissed`,v=`nextclaw-pwa-install-banner-dismissed-until`;function y(){let e=S();return e?e.getItem(`nextclaw-pwa-install-banner-dismissed`)===`1`?!0:C(e):!1}function b(){let e=S();e?.setItem(_,`1`),e?.removeItem(v)}function x(){let e=S();e?.removeItem(_),e?.removeItem(v)}function S(){if(typeof window>`u`)return null;try{return window.localStorage}catch{return null}}function C(e){let t=e.getItem(v);if(!t)return!1;let n=Number.parseInt(t,10);return e.removeItem(v),!Number.isFinite(n)||n<=Date.now()?!1:(e.setItem(_,`1`),!0)}function w(){return{initialized:!1,installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`,dismissedInstallPrompt:y()}}var T=s(()=>w()),E=new class{constructor(){this.started=!1,this.deferredPrompt=null,this.displayModeMediaQuery=null,this.start=()=>{this.started||typeof window>`u`||(this.started=!0,window.addEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.addEventListener(`appinstalled`,this.handleAppInstalled),typeof window.matchMedia==`function`&&(this.displayModeMediaQuery=window.matchMedia(`(display-mode: standalone)`),this.bindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged)),this.refreshState())},this.stop=()=>{!this.started||typeof window>`u`||(window.removeEventListener(`beforeinstallprompt`,this.handleBeforeInstallPrompt),window.removeEventListener(`appinstalled`,this.handleAppInstalled),this.displayModeMediaQuery&&=(this.unbindDisplayModeListener(this.displayModeMediaQuery,this.handleDisplayModeChanged),null),this.deferredPrompt=null,this.started=!1)},this.resetForTests=()=>{this.stop(),T.setState(w())},this.refreshState=()=>{let e=this.resolveInstallability();T.setState(t=>({...t,initialized:!0,installability:e.installability,installMethod:e.installMethod,blockedReason:e.blockedReason,dismissedInstallPrompt:y()}))},this.dismissInstallPrompt=()=>{b(),T.setState({dismissedInstallPrompt:!0})},this.promptInstall=async()=>{let e=this.resolveInstallability();if(e.installability!==`available`)return`unavailable`;if(e.installMethod===`manual`||!this.deferredPrompt)return`manual`;this.deferredPrompt.prompt();let t=await this.deferredPrompt.userChoice;return this.deferredPrompt=null,t.outcome===`accepted`?(x(),this.refreshState(),i.success(p(`pwaInstallAccepted`)),`accepted`):(this.dismissInstallPrompt(),this.refreshState(),`dismissed`)},this.handleBeforeInstallPrompt=e=>{e.preventDefault(),this.deferredPrompt=e,this.refreshState()},this.handleAppInstalled=()=>{this.deferredPrompt=null,x(),T.setState({dismissedInstallPrompt:!0}),i.success(p(`pwaInstalledToast`)),this.refreshState()},this.handleDisplayModeChanged=()=>{this.refreshState()},this.resolveInstallability=()=>this.isDevelopmentServer()?{installability:`unsupported`,installMethod:`none`,blockedReason:`dev-server`}:this.hasDesktopHost()?{installability:`suppressed`,installMethod:`none`,blockedReason:`desktop-host`}:this.isStandalone()?{installability:`installed`,installMethod:`none`,blockedReason:null}:this.hasInstallSurfaceSupport()?this.isEligibleInstallContext()?{installability:`available`,installMethod:this.deferredPrompt?`prompt`:`manual`,blockedReason:null}:{installability:`unsupported`,installMethod:`none`,blockedReason:`insecure-context`}:{installability:`unsupported`,installMethod:`none`,blockedReason:`missing-browser-support`},this.hasDesktopHost=()=>typeof window<`u`&&!!window.nextclawDesktop,this.hasInstallSurfaceSupport=()=>typeof window<`u`&&typeof window.matchMedia==`function`&&`serviceWorker`in navigator,this.isEligibleInstallContext=()=>typeof window>`u`?!1:window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>typeof window<`u`&&!1,this.isStandalone=()=>{if(typeof window>`u`)return!1;let e=window.navigator;return typeof window.matchMedia==`function`&&window.matchMedia(`(display-mode: standalone)`).matches||e.standalone===!0},this.bindDisplayModeListener=(e,t)=>{if(`addEventListener`in e){e.addEventListener(`change`,t);return}e.addListener?.(t)},this.unbindDisplayModeListener=(e,t)=>{if(`removeEventListener`in e){e.removeEventListener(`change`,t);return}e.removeListener?.(t)}}},D=l();function O(){let e=T(e=>e.installability);return(0,D.jsx)(`span`,{className:o(`inline-flex items-center rounded-full border px-3 py-1 text-xs font-medium`,e===`installed`?`bg-emerald-50 text-emerald-700 border-emerald-200`:e===`available`?`bg-amber-50 text-amber-700 border-amber-200`:`bg-gray-100 text-gray-600 border-gray-200`),children:k(e)})}function k(e){return p(e===`available`?`pwaInstallStatusAvailable`:e===`installed`?`pwaInstallStatusInstalled`:e===`suppressed`?`pwaInstallStatusDesktopHost`:`pwaInstallStatusUnavailable`)}function A(e,t,n){return p(e===`installed`?`pwaInstallCardInstalled`:e===`suppressed`?`pwaInstallCardSuppressed`:e===`available`&&t===`prompt`?`pwaInstallCardPrompt`:e===`available`?`pwaInstallCardManual`:n===`insecure-context`?`pwaInstallCardInsecureContext`:n===`dev-server`?`pwaInstallCardDevServer`:`pwaInstallCardUnsupported`)}function j(){let e=T(e=>e.installability),t=T(e=>e.installMethod),n=T(e=>e.blockedReason);return(0,D.jsx)(r,{title:p(`pwaInstallTitle`),description:p(`pwaInstallDescription`),actions:(0,D.jsx)(O,{}),children:(0,D.jsx)(c,{children:(0,D.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,D.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:A(e,t,n)}),e===`available`&&t===`prompt`?(0,D.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,D.jsxs)(a,{type:`button`,className:`gap-2`,onClick:()=>void E.promptInstall(),children:[(0,D.jsx)(d,{className:`h-4 w-4`}),p(`pwaInstallAction`)]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:p(`pwaInstallPromptHint`)})]}):null,e===`available`&&t===`manual`?(0,D.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-background/65 p-4`,children:[(0,D.jsx)(g,{className:`mt-0.5 h-4 w-4 text-muted-foreground`}),(0,D.jsx)(`p`,{className:`text-sm leading-6 text-muted-foreground`,children:p(`pwaInstallManualHint`)})]}):null]})})})}function M(){let e=T(e=>e.installability),t=T(e=>e.installMethod),n=T(e=>e.dismissedInstallPrompt);return e!==`available`||t!==`prompt`||n?null:(0,D.jsxs)(`div`,{className:`fixed bottom-5 right-5 z-50 w-[min(420px,calc(100vw-2rem))] rounded-[26px] border border-gray-200 bg-white/95 p-5 shadow-2xl backdrop-blur-xl`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,D.jsxs)(`div`,{className:`space-y-1`,children:[(0,D.jsx)(`p`,{className:`text-sm font-semibold text-gray-900`,children:p(`pwaInstallBannerTitle`)}),(0,D.jsx)(`p`,{className:`text-sm leading-6 text-gray-600`,children:p(`pwaInstallBannerDescription`)})]}),(0,D.jsx)(`button`,{type:`button`,"aria-label":p(`pwaInstallDismiss`),className:`rounded-full p-1 text-gray-400 transition hover:bg-[var(--interaction-hover)] hover:text-gray-600`,onClick:()=>{E.dismissInstallPrompt()},children:(0,D.jsx)(f,{className:`h-4 w-4`})})]}),(0,D.jsxs)(`div`,{className:`mt-4 flex items-center gap-3`,children:[(0,D.jsxs)(a,{type:`button`,size:`sm`,className:`gap-2`,onClick:()=>{E.promptInstall()},children:[(0,D.jsx)(d,{className:`h-4 w-4`}),p(`pwaInstallAction`)]}),(0,D.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{E.dismissInstallPrompt()},children:p(`pwaInstallDismiss`)})]})]})}var N=new class{constructor(){this.started=!1,this.registration=null,this.start=async()=>{if(!(this.started||typeof window>`u`)&&(this.started=!0,!(!(`serviceWorker`in navigator)||!this.isEligibleInstallContext()))){if(this.isDevelopmentServer()){await this.cleanupDevelopmentRegistrations();return}try{this.registration=await navigator.serviceWorker.register(`/sw.js`)}catch{return}}},this.stop=()=>{!this.started||typeof window>`u`||!(`serviceWorker`in navigator)||(this.started=!1,this.registration=null)},this.isEligibleInstallContext=()=>window.isSecureContext||this.isTrustedLocalhost(window.location.hostname),this.isTrustedLocalhost=e=>e===`localhost`||e===`127.0.0.1`||e===`::1`||e===`[::1]`,this.isDevelopmentServer=()=>!1,this.cleanupDevelopmentRegistrations=async()=>{if(typeof navigator.serviceWorker.getRegistrations!=`function`)return;let e=(await navigator.serviceWorker.getRegistrations()).filter(e=>[e.active?.scriptURL,e.installing?.scriptURL,e.waiting?.scriptURL].filter(e=>!!e).some(e=>e.endsWith(`/sw.js`)));await Promise.all(e.map(async e=>await e.unregister())),e.length>0&&await this.clearNextClawCaches()},this.clearNextClawCaches=async()=>{if(typeof window>`u`||!(`caches`in window)||typeof caches.keys!=`function`)return;let e=await caches.keys();await Promise.all(e.filter(e=>e.startsWith(`nextclaw-ui-`)).map(async e=>await caches.delete(e)))}}},P=!1;function F(){P||typeof window>`u`||(P=!0,E.start(),N.start())}export{h as i,M as n,j as r,F as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e}from"./app-presenter-provider-Cx9MwMtb.js";export{e as RemoteAccessPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DF37yw5_.js";import{r as t}from"./pwa-Cp7pPvsZ.js";import{Gt as n,Jt as r,Kt as i,Ut as a,Xn as o,Yt as s,Zt as c,dn as l,ln as u,pn as d,qt as f,sn as p,ur as m,xr as h}from"./api-CXWxExzS.js";import{L as g,R as _,Zt as v,ft as y}from"./app-presenter-provider-BB3Xl8b0.js";import{X as b}from"./context-menu-C0qywo73.js";import{i as x}from"./x-waP-WLuT.js";import{t as S}from"./plus-C42o6xrD.js";import{t as C}from"./rotate-cw-CWFIat29.js";import{t as w}from"./save-C1G0ZU-G.js";import{t as T}from"./trash-2-BVQs-0ji.js";import{s as E}from"./i18n-ByVUrt9w.js";import{a as D,i as O,n as k,r as A,t as j}from"./select-BJ-EjmCz.js";import{b as M,t as ee}from"./use-config-M1L4xn8c.js";import{t as te}from"./form-actions-CZxcWXSm.js";var N=e(h(),1),P=m(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return E(F[e]??`runtimeControlUnavailable`)}function z(e){return E(I[e]??`runtimeControlServiceUnknown`)}function B(e){return E(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:E(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:E(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:E(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:E(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(x,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(b,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(v,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(C,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:a,visibleLifecycle:c,visibleMessage:u,visibleServiceState:m}=p(),h=H(n??void 0),g=async e=>{let t=V(n,e);if(!t?.available){o.error(d(t?.reasonIfUnavailable)??E(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(E(`runtimeControlStopServiceConfirm`))))try{let t=await l.runRuntimeControlAction(e);o.success(d(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:E(`runtimeControlActionFailed`);o.error(`${E(`runtimeControlActionFailed`)}: ${t}`)}},_=async()=>{if(!n?.canRestartApp.available){o.error(d(n?.canRestartApp.reasonIfUnavailable)??E(`runtimeRestartAppUnavailable`));return}if(window.confirm(E(`runtimeControlRestartAppConfirm`)))try{let e=await l.runRuntimeControlAction(`restart-app`);o.success(d(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:E(`runtimeControlActionFailed`);o.error(`${E(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(r,{title:E(`runtimeControlTitle`),description:E(`runtimeControlDescription`),children:(0,P.jsxs)(f,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(m)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n?B(n):E(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(c)}),n?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(n.managementHint)}):null,i&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),a?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:E(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:E(`runtimeControlPendingRestartDescription`)}),a.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:E(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:h.map(n=>(0,P.jsxs)(s,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){_();return}g(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),h.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(y,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(r,{title:E(`runtimePresenceTitle`),description:E(`runtimePresenceDescription`),children:(0,P.jsx)(f,{children:t})})}function q(){let e=u().runtimeControlView?.environment,t=_(e=>e.supported),n=_(e=>e.initialized),r=_(e=>e.busyAction),o=_(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){g.start();return}g.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(y,{tone:`neutral`,title:E(`runtimePresenceBehaviorLabel`),description:o?.closeToBackground?E(`runtimePresenceBehaviorBackground`):E(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!n||t&&!o?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:E(`runtimePresenceLoading`)}):null,o?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(i,{title:E(`runtimePresenceCloseToBackground`),description:E(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(a,{id:`runtime-presence-close-background`,"aria-label":E(`runtimePresenceCloseToBackground`),checked:o.closeToBackground,disabled:r===`saving-preferences`,onCheckedChange:e=>{g.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(i,{title:E(`runtimePresenceLaunchAtLogin`),description:o.supportsLaunchAtLogin?E(`runtimePresenceLaunchAtLoginHelp`):o.launchAtLoginReason??E(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(a,{id:`runtime-presence-launch-login`,"aria-label":E(`runtimePresenceLaunchAtLogin`),checked:o.launchAtLogin,disabled:!o.supportsLaunchAtLogin||r===`saving-preferences`,onCheckedChange:e=>{g.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceManagedLocalTitle`),description:E(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceSelfHostedTitle`),description:E(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceSharedTitle`),description:E(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:E(`runtimePresenceLoading`)})})}function J(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(q,{}),(0,P.jsx)(t,{})]})}var Y={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function X(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0}}function Z(){return{agentId:``,match:{channel:``,accountId:``}}}function Q(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Y,configText:JSON.stringify(Y,null,2)}}function ne(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens}}function re(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function ie(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(ne),bindings:(e.bindings??[]).map(re),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(E(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${E(`duplicateAgentId`)}: ${n[0]}`);let r=e.bindings.map((t,n)=>{let r=t.agentId.trim(),i=t.match.channel.trim(),a=t.match.accountId?.trim()??``,o=t.match.peer?.kind,s=t.match.peer?.id?.trim()??``;if(!r)throw Error(E(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(r))throw Error(`${E(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(E(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(E(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c}),i=e.runtimeEntries.reduce((e,t,n)=>{let r=t.id.trim(),i=t.type.trim();if(!r)throw Error(E(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!i)throw Error(E(`runtimeEntryTypeRequired`).replace(`{id}`,r));if(e[r])throw Error(`${E(`runtimeEntryDuplicate`)}: ${r}`);let a=t.configText.trim()?JSON.parse(t.configText):{};if(a&&(typeof a!=`object`||Array.isArray(a)))throw Error(E(`runtimeEntryConfigObjectRequired`).replace(`{id}`,r));return e[r]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:i,config:a??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:i}},bindings:r,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:i,onSetDefaultAgent:o,onUpdateAgent:c}){return(0,P.jsx)(r,{title:E(`agentList`),description:E(`agentListHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addAgent`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(n,{value:e.id,onChange:e=>c(t,{id:e.target.value}),placeholder:E(`agentIdPlaceholder`)}),(0,P.jsx)(n,{value:e.workspace??``,onChange:e=>c(t,{workspace:e.target.value}),placeholder:E(`workspaceOverridePlaceholder`)}),(0,P.jsx)(n,{value:e.model??``,onChange:e=>c(t,{model:e.target.value}),placeholder:E(`modelOverridePlaceholder`)}),(0,P.jsx)(n,{value:e.runtime??e.engine??``,onChange:e=>c(t,{runtime:e.target.value}),placeholder:E(`engineOverridePlaceholder`)}),(0,P.jsx)(n,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>c(t,{contextTokens:ie(e.target.value)}),placeholder:E(`contextTokensPlaceholder`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(a,{checked:!!e.default,onCheckedChange:e=>o(t,e)}),(0,P.jsx)(`span`,{children:E(`defaultAgent`)})]}),(0,P.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`h-4 w-4 mr-1`}),E(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:i,onUpdateBinding:a}){return(0,P.jsx)(r,{title:E(`bindings`),description:E(`bindingsHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addBinding`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>{let r=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(n,{value:e.agentId,onChange:n=>a(t,{...e,agentId:n.target.value}),placeholder:E(`targetAgentIdPlaceholder`)}),(0,P.jsx)(n,{value:e.match.channel,onChange:n=>a(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:E(`channelPlaceholder`)}),(0,P.jsx)(n,{value:e.match.accountId??``,onChange:n=>a(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:E(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(j,{value:r||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;a(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(O,{children:(0,P.jsx)(D,{})}),(0,P.jsxs)(k,{children:[(0,P.jsx)(A,{value:`__none__`,children:E(`peerKindOptional`)}),(0,P.jsx)(A,{value:`direct`,children:E(`peerKindDirect`)}),(0,P.jsx)(A,{value:`group`,children:E(`peerKindGroup`)}),(0,P.jsx)(A,{value:`channel`,children:E(`peerKindChannel`)})]})]}),(0,P.jsx)(n,{value:e.match.peer?.id??``,onChange:n=>a(t,{...e,match:{...e.match,peer:r?{kind:r,id:n.target.value}:void 0}}),placeholder:E(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`h-4 w-4 mr-1`}),E(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:i,onUpdateEntry:o}){return(0,P.jsx)(r,{title:E(`runtimeEntries`),description:E(`runtimeEntriesHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addRuntimeEntry`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(n,{value:e.id,onChange:e=>o(t,{id:e.target.value}),placeholder:E(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(n,{value:e.label??``,onChange:e=>o(t,{label:e.target.value}),placeholder:E(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(n,{value:e.type,onChange:e=>o(t,{type:e.target.value}),placeholder:E(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:E(`enabled`)}),(0,P.jsx)(a,{checked:e.enabled!==!1,onCheckedChange:e=>o(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:E(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>o(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(s,{type:`button`,variant:`outline`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`mr-2 h-4 w-4`}),E(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:o,dmScope:s,onCompanionEnabledChange:c,onDefaultContextTokensChange:l,onDefaultEngineChange:u,onDmScopeChange:d}){return(0,P.jsx)(r,{title:E(`dmScope`),description:E(`dmScopeHelp`),children:(0,P.jsxs)(f,{children:[(0,P.jsx)(i,{title:E(`runtimeCompanionEnabled`),description:E(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(a,{checked:e,onCheckedChange:c})}),(0,P.jsx)(i,{title:E(`defaultContextTokens`),description:E(`defaultContextTokensHelp`),control:(0,P.jsx)(n,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>l(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(i,{title:E(`defaultEngine`),description:E(`defaultEngineHelp`),control:(0,P.jsx)(n,{value:o,onChange:e=>u(e.target.value),placeholder:E(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(i,{title:E(`dmScope`),control:(0,P.jsxs)(j,{value:s,onValueChange:e=>d(e),children:[(0,P.jsx)(O,{className:`w-56`,children:(0,P.jsx)(D,{})}),(0,P.jsx)(k,{children:ue.map(e=>(0,P.jsx)(A,{value:e.value,children:E(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let n=(0,N.useMemo)(()=>ae(e),[e]),[r,i]=(0,N.useState)(n.agents),[a,l]=(0,N.useState)(n.bindings),[u,d]=(0,N.useState)(n.runtimeEntries),[f,p]=(0,N.useState)(n.dmScope),[m,h]=(0,N.useState)(n.companionEnabled),[g,_]=(0,N.useState)(n.defaultContextTokens),[v,y]=(0,N.useState)(n.defaultEngine),b=(0,N.useMemo)(()=>{let e=new Set([`main`]);return r.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[r]);return(0,P.jsxs)(c,{title:E(`runtimePageTitle`),description:E(`runtimePageDescription`),children:[(0,P.jsx)(J,{}),(0,P.jsx)(de,{companionEnabled:m,dmScope:f,defaultContextTokens:g,defaultEngine:v,onCompanionEnabledChange:h,onDmScopeChange:p,onDefaultContextTokensChange:_,onDefaultEngineChange:y}),(0,P.jsx)(le,{entries:u,onUpdateEntry:(e,t)=>d(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>d(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>d(e=>[...e,Q()])}),(0,P.jsx)(se,{agents:r,onUpdateAgent:(e,t)=>{i(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>i(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>i(e=>[...e,X()]),onSetDefaultAgent:(e,t)=>i(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:a,onUpdateBinding:(e,t)=>{l(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>l(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>l(e=>[...e,Z()])}),(0,P.jsx)(te,{children:(0,P.jsxs)(s,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:m,agents:r,bindings:a,runtimeEntries:u,dmScope:f,defaultContextTokens:g,defaultEngine:v,knownAgentIds:b});t.mutate({data:e})}catch(e){o.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(w,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?E(`saving`):E(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=ee(),n=M();return t||!e?(0,P.jsx)(c,{title:E(`runtimePageTitle`),description:E(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:E(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:n})}export{pe as RuntimeConfig};
|
|
1
|
+
import{i as e}from"./chunk-DF37yw5_.js";import{r as t}from"./pwa-jmuWbrqH.js";import{Gt as n,Jt as r,Kt as i,Ut as a,Xn as o,Yt as s,Zt as c,dn as l,ln as u,pn as d,qt as f,sn as p,ur as m,xr as h}from"./api-CXWxExzS.js";import{L as g,R as _,Zt as v,ft as y}from"./app-presenter-provider-Cx9MwMtb.js";import{X as b}from"./context-menu-C6m-WNpl.js";import{i as x}from"./x-waP-WLuT.js";import{t as S}from"./plus-C42o6xrD.js";import{t as C}from"./rotate-cw-CWFIat29.js";import{t as w}from"./save-C1G0ZU-G.js";import{t as T}from"./trash-2-BVQs-0ji.js";import{s as E}from"./i18n-ByVUrt9w.js";import{a as D,i as O,n as k,r as A,t as j}from"./select-BJ-EjmCz.js";import{b as M,t as ee}from"./use-config-M1L4xn8c.js";import{t as te}from"./form-actions-CZxcWXSm.js";var N=e(h(),1),P=m(),F={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},I={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},L={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function R(e){return E(F[e]??`runtimeControlUnavailable`)}function z(e){return E(I[e]??`runtimeControlServiceUnknown`)}function B(e){return E(L[e.environment])}function V(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function H(e){return e?[{action:`start-service`,capability:e.canStartService,label:E(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:E(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:E(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:E(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function U(e){let{busy:t,icon:n}=e;return t?(0,P.jsx)(x,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,P.jsx)(b,{className:`mr-2 h-4 w-4`}):n===`square`?(0,P.jsx)(v,{className:`mr-2 h-4 w-4`}):(0,P.jsx)(C,{className:`mr-2 h-4 w-4`})}function W(){let{busy:e,busyAction:t,controlView:n,errorMessage:i,pendingRestart:a,visibleLifecycle:c,visibleMessage:u,visibleServiceState:m}=p(),h=H(n??void 0),g=async e=>{let t=V(n,e);if(!t?.available){o.error(d(t?.reasonIfUnavailable)??E(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&t.requiresConfirmation&&!window.confirm(E(`runtimeControlStopServiceConfirm`))))try{let t=await l.runRuntimeControlAction(e);o.success(d(t.message)??t.message)}catch(e){let t=e instanceof Error?e.message:E(`runtimeControlActionFailed`);o.error(`${E(`runtimeControlActionFailed`)}: ${t}`)}},_=async()=>{if(!n?.canRestartApp.available){o.error(d(n?.canRestartApp.reasonIfUnavailable)??E(`runtimeRestartAppUnavailable`));return}if(window.confirm(E(`runtimeControlRestartAppConfirm`)))try{let e=await l.runRuntimeControlAction(`restart-app`);o.success(d(e.message)??e.message)}catch(e){let t=e instanceof Error?e.message:E(`runtimeControlActionFailed`);o.error(`${E(`runtimeControlActionFailed`)}: ${t}`)}};return(0,P.jsx)(r,{title:E(`runtimeControlTitle`),description:E(`runtimeControlDescription`),children:(0,P.jsxs)(f,{children:[(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:z(m)}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n?B(n):E(`runtimeControlLoading`)})]}),(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:u}),(0,P.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:R(c)}),n?.managementHint?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(n.managementHint)}):null,i&&!e?(0,P.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),a?(0,P.jsxs)(`div`,{className:`space-y-3 bg-amber-50/75 p-4 dark:bg-amber-950/20`,children:[(0,P.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:E(`runtimeControlPendingRestartTitle`)}),(0,P.jsx)(`p`,{className:`text-sm text-amber-800`,children:E(`runtimeControlPendingRestartDescription`)}),a.changedPaths.length>0?(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:E(`runtimeControlPendingRestartPaths`)}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a.changedPaths.map(e=>(0,P.jsx)(`span`,{className:`rounded-full bg-background/80 px-2.5 py-1 text-xs text-amber-800 dark:text-amber-300`,children:e},e))})]}):null]}):null,(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:h.map(n=>(0,P.jsxs)(s,{type:`button`,variant:n.variant??`default`,onClick:()=>{if(n.action===`restart-app`){_();return}g(n.action)},disabled:!n.capability.available||e,children:[(0,P.jsx)(U,{icon:n.icon,busy:t===n.action}),n.label]},n.action))}),h.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d(e.capability.reasonIfUnavailable)},`${e.action}-reason`))]})]})})}function G(e){let{description:t,title:n}=e;return(0,P.jsx)(y,{tone:`neutral`,title:n,description:t})}function K(e){let{children:t}=e;return(0,P.jsx)(r,{title:E(`runtimePresenceTitle`),description:E(`runtimePresenceDescription`),children:(0,P.jsx)(f,{children:t})})}function q(){let e=u().runtimeControlView?.environment,t=_(e=>e.supported),n=_(e=>e.initialized),r=_(e=>e.busyAction),o=_(e=>e.snapshot);return(0,N.useEffect)(()=>{if(e===`desktop-embedded`){g.start();return}g.markUnsupported()},[e]),e===`desktop-embedded`?(0,P.jsxs)(K,{children:[(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(y,{tone:`neutral`,title:E(`runtimePresenceBehaviorLabel`),description:o?.closeToBackground?E(`runtimePresenceBehaviorBackground`):E(`runtimePresenceBehaviorQuit`),className:`rounded-xl`})}),!n||t&&!o?(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:E(`runtimePresenceLoading`)}):null,o?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(i,{title:E(`runtimePresenceCloseToBackground`),description:E(`runtimePresenceCloseToBackgroundHelp`),control:(0,P.jsx)(a,{id:`runtime-presence-close-background`,"aria-label":E(`runtimePresenceCloseToBackground`),checked:o.closeToBackground,disabled:r===`saving-preferences`,onCheckedChange:e=>{g.updatePreferences({closeToBackground:e})}})}),(0,P.jsx)(i,{title:E(`runtimePresenceLaunchAtLogin`),description:o.supportsLaunchAtLogin?E(`runtimePresenceLaunchAtLoginHelp`):o.launchAtLoginReason??E(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,P.jsx)(a,{id:`runtime-presence-launch-login`,"aria-label":E(`runtimePresenceLaunchAtLogin`),checked:o.launchAtLogin,disabled:!o.supportsLaunchAtLogin||r===`saving-preferences`,onCheckedChange:e=>{g.updatePreferences({launchAtLogin:e})}})})]}):null]}):e===`managed-local-service`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceManagedLocalTitle`),description:E(`runtimePresenceManagedLocalDescription`)})})}):e===`self-hosted-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceSelfHostedTitle`),description:E(`runtimePresenceSelfHostedDescription`)})})}):e===`shared-web`?(0,P.jsx)(K,{children:(0,P.jsx)(`div`,{className:`p-4`,children:(0,P.jsx)(G,{title:E(`runtimePresenceSharedTitle`),description:E(`runtimePresenceSharedDescription`)})})}):(0,P.jsx)(K,{children:(0,P.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:E(`runtimePresenceLoading`)})})}function J(){return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(W,{}),(0,P.jsx)(q,{}),(0,P.jsx)(t,{})]})}var Y={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function X(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0}}function Z(){return{agentId:``,match:{channel:``,accountId:``}}}function Q(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Y,configText:JSON.stringify(Y,null,2)}}function ne(e){return{id:e.id??``,default:!!e.default,displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,workspace:e.workspace??``,model:e.model??``,runtime:e.runtime??e.engine??``,contextTokens:e.contextTokens}}function re(e){return{agentId:e.agentId??``,match:{channel:e.match?.channel??``,accountId:e.match?.accountId??``,peer:e.match?.peer?{kind:e.match.peer.kind,id:e.match.peer.id}:void 0}}}function ie(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function ae(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(ne),bindings:(e.bindings??[]).map(re),runtimeEntries:Object.entries(e.agents.runtimes?.entries??{}).map(([e,t])=>({id:e,enabled:t.enabled!==!1,label:t.label??``,type:t.type,config:t.config??{},configText:JSON.stringify(t.config??{},null,2)})),dmScope:e.session?.dmScope??`per-channel-peer`,defaultContextTokens:e.agents.defaults.contextTokens??2e5,defaultEngine:e.agents.defaults.engine??`native`}}function oe(e){let t={id:e.id.trim()};e.default&&(t.default=!0),e.displayName?.trim()&&(t.displayName=e.displayName.trim()),e.description?.trim()&&(t.description=e.description.trim()),e.avatar?.trim()&&(t.avatar=e.avatar.trim()),e.workspace?.trim()&&(t.workspace=e.workspace.trim()),e.model?.trim()&&(t.model=e.model.trim());let n=e.runtime?.trim()??e.engine?.trim();return n&&(t.engine=n),typeof e.contextTokens==`number`&&(t.contextTokens=Math.max(1e3,e.contextTokens)),t}function $(e){let t=e.agents.map((e,t)=>{if(!e.id.trim())throw Error(E(`agentIdRequiredError`).replace(`{index}`,String(t)));return oe(e)}),n=t.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(n.length>0)throw Error(`${E(`duplicateAgentId`)}: ${n[0]}`);let r=e.bindings.map((t,n)=>{let r=t.agentId.trim(),i=t.match.channel.trim(),a=t.match.accountId?.trim()??``,o=t.match.peer?.kind,s=t.match.peer?.id?.trim()??``;if(!r)throw Error(E(`bindingAgentIdRequired`).replace(`{index}`,String(n)));if(!e.knownAgentIds.has(r))throw Error(`${E(`bindingAgentIdNotFound`).replace(`{index}`,String(n))}: ${r}`);if(!i)throw Error(E(`bindingChannelRequired`).replace(`{index}`,String(n)));let c={agentId:r,match:{channel:i}};if(a&&(c.match.accountId=a),o){if(!s)throw Error(E(`bindingPeerIdRequired`).replace(`{index}`,String(n)));c.match.peer={kind:o,id:s}}return c}),i=e.runtimeEntries.reduce((e,t,n)=>{let r=t.id.trim(),i=t.type.trim();if(!r)throw Error(E(`runtimeEntryIdRequired`).replace(`{index}`,String(n)));if(!i)throw Error(E(`runtimeEntryTypeRequired`).replace(`{id}`,r));if(e[r])throw Error(`${E(`runtimeEntryDuplicate`)}: ${r}`);let a=t.configText.trim()?JSON.parse(t.configText):{};if(a&&(typeof a!=`object`||Array.isArray(a)))throw Error(E(`runtimeEntryConfigObjectRequired`).replace(`{id}`,r));return e[r]={enabled:t.enabled!==!1,...t.label?.trim()?{label:t.label.trim()}:{},type:i,config:a??{}},e},{});return{companion:{enabled:e.companionEnabled},agents:{defaults:{contextTokens:Math.max(1e3,e.defaultContextTokens),engine:e.defaultEngine.trim()||`native`},list:t,runtimes:{entries:i}},bindings:r,session:{dmScope:e.dmScope}}}function se({agents:e,onAddAgent:t,onRemoveAgent:i,onSetDefaultAgent:o,onUpdateAgent:c}){return(0,P.jsx)(r,{title:E(`agentList`),description:E(`agentListHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addAgent`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(n,{value:e.id,onChange:e=>c(t,{id:e.target.value}),placeholder:E(`agentIdPlaceholder`)}),(0,P.jsx)(n,{value:e.workspace??``,onChange:e=>c(t,{workspace:e.target.value}),placeholder:E(`workspaceOverridePlaceholder`)}),(0,P.jsx)(n,{value:e.model??``,onChange:e=>c(t,{model:e.target.value}),placeholder:E(`modelOverridePlaceholder`)}),(0,P.jsx)(n,{value:e.runtime??e.engine??``,onChange:e=>c(t,{runtime:e.target.value}),placeholder:E(`engineOverridePlaceholder`)}),(0,P.jsx)(n,{type:`number`,min:1e3,step:1e3,value:e.contextTokens??``,onChange:e=>c(t,{contextTokens:ie(e.target.value)}),placeholder:E(`contextTokensPlaceholder`)})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,P.jsx)(a,{checked:!!e.default,onCheckedChange:e=>o(t,e)}),(0,P.jsx)(`span`,{children:E(`defaultAgent`)})]}),(0,P.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`h-4 w-4 mr-1`}),E(`remove`)]})]})]},`${t}-${e.id}`))})})}function ce({bindings:e,onAddBinding:t,onRemoveBinding:i,onUpdateBinding:a}){return(0,P.jsx)(r,{title:E(`bindings`),description:E(`bindingsHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addBinding`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>{let r=e.match.peer?.kind??``;return(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,P.jsx)(n,{value:e.agentId,onChange:n=>a(t,{...e,agentId:n.target.value}),placeholder:E(`targetAgentIdPlaceholder`)}),(0,P.jsx)(n,{value:e.match.channel,onChange:n=>a(t,{...e,match:{...e.match,channel:n.target.value}}),placeholder:E(`channelPlaceholder`)}),(0,P.jsx)(n,{value:e.match.accountId??``,onChange:n=>a(t,{...e,match:{...e.match,accountId:n.target.value}}),placeholder:E(`accountIdOptionalPlaceholder`)}),(0,P.jsxs)(j,{value:r||`__none__`,onValueChange:n=>{let r=n===`__none__`?``:n;a(t,r?{...e,match:{...e.match,peer:{kind:r,id:e.match.peer?.id??``}}}:{...e,match:{...e.match,peer:void 0}})},children:[(0,P.jsx)(O,{children:(0,P.jsx)(D,{})}),(0,P.jsxs)(k,{children:[(0,P.jsx)(A,{value:`__none__`,children:E(`peerKindOptional`)}),(0,P.jsx)(A,{value:`direct`,children:E(`peerKindDirect`)}),(0,P.jsx)(A,{value:`group`,children:E(`peerKindGroup`)}),(0,P.jsx)(A,{value:`channel`,children:E(`peerKindChannel`)})]})]}),(0,P.jsx)(n,{value:e.match.peer?.id??``,onChange:n=>a(t,{...e,match:{...e.match,peer:r?{kind:r,id:n.target.value}:void 0}}),placeholder:E(`peerIdPlaceholder`)})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(s,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`h-4 w-4 mr-1`}),E(`remove`)]})})]},`${t}-${e.agentId}`)})})})}function le({entries:e,onAddEntry:t,onRemoveEntry:i,onUpdateEntry:o}){return(0,P.jsx)(r,{title:E(`runtimeEntries`),description:E(`runtimeEntriesHelp`),actions:(0,P.jsxs)(s,{type:`button`,variant:`ghost`,size:`sm`,onClick:t,children:[(0,P.jsx)(S,{className:`mr-2 h-4 w-4`}),E(`addRuntimeEntry`)]}),children:(0,P.jsx)(f,{children:e.map((e,t)=>(0,P.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,P.jsx)(n,{value:e.id,onChange:e=>o(t,{id:e.target.value}),placeholder:E(`runtimeEntryIdPlaceholder`)}),(0,P.jsx)(n,{value:e.label??``,onChange:e=>o(t,{label:e.target.value}),placeholder:E(`runtimeEntryLabelPlaceholder`)}),(0,P.jsx)(n,{value:e.type,onChange:e=>o(t,{type:e.target.value}),placeholder:E(`runtimeEntryTypePlaceholder`)}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg bg-background/65 px-3 py-2`,children:[(0,P.jsx)(`span`,{className:`text-sm text-foreground`,children:E(`enabled`)}),(0,P.jsx)(a,{checked:e.enabled!==!1,onCheckedChange:e=>o(t,{enabled:e})})]})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-foreground`,children:E(`runtimeEntryConfigJson`)}),(0,P.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-input bg-background px-3 py-2 font-mono text-sm`,value:e.configText,onChange:e=>o(t,{configText:e.target.value}),spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsxs)(s,{type:`button`,variant:`outline`,onClick:()=>i(t),children:[(0,P.jsx)(T,{className:`mr-2 h-4 w-4`}),E(`delete`)]})})]},`${t}-${e.id||`runtime-entry`}`))})})}var ue=[{value:`main`,labelKey:`dmScopeMain`},{value:`per-peer`,labelKey:`dmScopePerPeer`},{value:`per-channel-peer`,labelKey:`dmScopePerChannelPeer`},{value:`per-account-channel-peer`,labelKey:`dmScopePerAccountChannelPeer`}];function de({companionEnabled:e,defaultContextTokens:t,defaultEngine:o,dmScope:s,onCompanionEnabledChange:c,onDefaultContextTokensChange:l,onDefaultEngineChange:u,onDmScopeChange:d}){return(0,P.jsx)(r,{title:E(`dmScope`),description:E(`dmScopeHelp`),children:(0,P.jsxs)(f,{children:[(0,P.jsx)(i,{title:E(`runtimeCompanionEnabled`),description:E(`runtimeCompanionEnabledHelp`),control:(0,P.jsx)(a,{checked:e,onCheckedChange:c})}),(0,P.jsx)(i,{title:E(`defaultContextTokens`),description:E(`defaultContextTokensHelp`),control:(0,P.jsx)(n,{type:`number`,min:1e3,step:1e3,value:t,onChange:e=>l(Math.max(1e3,Number.parseInt(e.target.value,10)||1e3)),className:`w-36`})}),(0,P.jsx)(i,{title:E(`defaultEngine`),description:E(`defaultEngineHelp`),control:(0,P.jsx)(n,{value:o,onChange:e=>u(e.target.value),placeholder:E(`defaultEnginePlaceholder`),className:`w-56`})}),(0,P.jsx)(i,{title:E(`dmScope`),control:(0,P.jsxs)(j,{value:s,onValueChange:e=>d(e),children:[(0,P.jsx)(O,{className:`w-56`,children:(0,P.jsx)(D,{})}),(0,P.jsx)(k,{children:ue.map(e=>(0,P.jsx)(A,{value:e.value,children:E(e.labelKey)},e.value))})]})})]})})}function fe({config:e,updateRuntime:t}){let n=(0,N.useMemo)(()=>ae(e),[e]),[r,i]=(0,N.useState)(n.agents),[a,l]=(0,N.useState)(n.bindings),[u,d]=(0,N.useState)(n.runtimeEntries),[f,p]=(0,N.useState)(n.dmScope),[m,h]=(0,N.useState)(n.companionEnabled),[g,_]=(0,N.useState)(n.defaultContextTokens),[v,y]=(0,N.useState)(n.defaultEngine),b=(0,N.useMemo)(()=>{let e=new Set([`main`]);return r.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[r]);return(0,P.jsxs)(c,{title:E(`runtimePageTitle`),description:E(`runtimePageDescription`),children:[(0,P.jsx)(J,{}),(0,P.jsx)(de,{companionEnabled:m,dmScope:f,defaultContextTokens:g,defaultEngine:v,onCompanionEnabledChange:h,onDmScopeChange:p,onDefaultContextTokensChange:_,onDefaultEngineChange:y}),(0,P.jsx)(le,{entries:u,onUpdateEntry:(e,t)=>d(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>d(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>d(e=>[...e,Q()])}),(0,P.jsx)(se,{agents:r,onUpdateAgent:(e,t)=>{i(n=>n.map((n,r)=>r===e?{...n,...t}:n))},onRemoveAgent:e=>i(t=>t.filter((t,n)=>n!==e)),onAddAgent:()=>i(e=>[...e,X()]),onSetDefaultAgent:(e,t)=>i(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t))}),(0,P.jsx)(ce,{bindings:a,onUpdateBinding:(e,t)=>{l(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>l(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>l(e=>[...e,Z()])}),(0,P.jsx)(te,{children:(0,P.jsxs)(s,{type:`button`,size:`sm`,onClick:()=>{try{let e=$({companionEnabled:m,agents:r,bindings:a,runtimeEntries:u,dmScope:f,defaultContextTokens:g,defaultEngine:v,knownAgentIds:b});t.mutate({data:e})}catch(e){o.error(e instanceof Error?e.message:String(e))}},disabled:t.isPending,children:[(0,P.jsx)(w,{className:`mr-1.5 h-3.5 w-3.5`}),t.isPending?E(`saving`):E(`saveRuntimeSettings`)]})})]})}function pe(){let{data:e,isLoading:t}=ee(),n=M();return t||!e?(0,P.jsx)(c,{title:E(`runtimePageTitle`),description:E(`runtimePageDescription`),children:(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:E(`runtimeLoading`)})}):(0,P.jsx)(fe,{config:e,updateRuntime:n})}export{pe as RuntimeConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./chunk-DF37yw5_.js";import{S as t}from"./theme-provider-BsJ6HxeX.js";import{Lt as n,Qn as r,Yt as i,Zn as a,_n as o,lr as s,ur as c,xr as l}from"./api-CXWxExzS.js";import{$t as u,Ft as d,Nt as f,Pt as p,d as m,en as h,m as g,rn as _,zt as ee}from"./app-presenter-provider-BB3Xl8b0.js";import{t as v}from"./createLucideIcon-C3LSyx-e.js";import{G as y,W as b,g as x,h as S,ut as C,yt as w}from"./context-menu-C0qywo73.js";import{z as T}from"./dist-D9h2cWk3.js";import{t as E}from"./circle-dashed-KGwElDWV.js";import{i as D}from"./x-waP-WLuT.js";import{t as O}from"./refresh-cw-DOg2pWGu.js";import{t as k}from"./trash-2-BVQs-0ji.js";import{s as A}from"./i18n-ByVUrt9w.js";import{a as j,d as M,f as N,i as P,l as F,n as I,o as L,r as R,t as z,u as B}from"./dialog-DMKYZDFu.js";import{g as V,h as H,p as U}from"./provider-models-D8WOdsdu.js";var W=v(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),te=v(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),G=v(`ShieldPlus`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9 12h6`,key:`1c52cq`}],[`path`,{d:`M12 9v6`,key:`199k2o`}]]),ne=v(`Unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),K=e(l(),1),q=c();function re({appId:e,appTitle:t,dataEntry:n,dataLoading:r,deleteError:a,deletePending:o,open:s,purgeData:c,onDelete:l,onOpenChange:u,onPurgeDataChange:f}){let m=(0,K.useRef)(null);(0,K.useEffect)(()=>{a&&m.current?.focus()},[a]);let h=()=>u(!1);return(0,q.jsx)(z,{open:s,onOpenChange:e=>!o&&u(e),children:(0,q.jsxs)(I,{className:`max-w-md`,onEscapeKeyDown:e=>o&&e.preventDefault(),onInteractOutside:e=>o&&e.preventDefault(),children:[(0,q.jsxs)(j,{showClose:!1,children:[(0,q.jsx)(L,{children:A(`serviceAppsDeleteConfirmTitle`)}),(0,q.jsxs)(R,{children:[A(`serviceAppsDeleteConfirmDescription`),` `,t]})]}),(0,q.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,q.jsx)(d,{checked:!c,description:A(`serviceAppsKeepDataDescription`),label:A(`appPackagesKeepData`),onClick:()=>f(!1)}),(0,q.jsx)(d,{checked:c,destructive:!0,disabled:!n||r,description:A(`serviceAppsDeleteDataDescription`),label:A(`appPackagesDeleteData`),onClick:()=>f(!0)})]}),n?(0,q.jsx)(`div`,{className:`mt-3`,children:(0,q.jsx)(p,{storage:n.storage,usage:n.usage})}):(0,q.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-muted-foreground`,children:A(r?`appPackagesLoading`:`serviceAppsDataUnavailable`)}),a?(0,q.jsx)(`p`,{ref:m,role:`alert`,tabIndex:-1,className:`mt-3 text-xs text-destructive`,children:a instanceof Error?a.message:A(`appPackagesActionFailed`)}):null,(0,q.jsxs)(P,{className:`mt-5 gap-2 sm:gap-0`,children:[(0,q.jsx)(i,{autoFocus:!0,type:`button`,variant:`outline`,disabled:o,onClick:h,children:A(`cancel`)}),(0,q.jsxs)(i,{type:`button`,variant:c?`destructive`:`default`,disabled:o||c&&!n,onClick:()=>l(e,c,h),children:[o?(0,q.jsx)(D,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):null,A(c?`appDataDeletePermanently`:`serviceAppsDelete`)]})]})]})})}function ie({action:e,grants:t,agents:n,grantAgentPending:r,onGrantAgent:i,onRevoke:a}){let[o,s]=(0,K.useState)(!1),c=new Set(t.flatMap(e=>e.caller.surface===`agent`?[e.caller.agentId]:[])),l=n.filter(e=>!c.has(e.id));return(0,q.jsxs)(`div`,{className:`py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center text-muted-foreground`,children:(0,q.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-xs font-medium text-foreground`,children:e.title??e.name}),e.description?(0,q.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:e.description}):null]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:A(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.risk}),(0,q.jsxs)(U,{open:o,onOpenChange:s,children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,disabled:r||l.length===0,className:`ml-1 rounded-md p-1 text-muted-foreground/70 transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:cursor-not-allowed disabled:opacity-40`,title:A(`serviceAppsGrantToAgent`),"aria-label":A(`serviceAppsGrantToAgent`),children:(0,q.jsx)(G,{className:`h-3.5 w-3.5`})})}),(0,q.jsxs)(H,{align:`end`,variant:`menu`,children:[(0,q.jsx)(`div`,{className:`px-2 py-1.5 text-[11px] font-medium text-muted-foreground`,children:A(`serviceAppsGrantToAgent`)}),l.map(t=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{i(e.id,t.id),s(!1)},className:`${x} text-foreground ${S.item}`,children:[(0,q.jsx)(w,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.displayName?.trim()||t.id})]},t.id))]})]})]})]}),t.map(e=>(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-2 pl-8`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,q.jsx)(u,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,q.jsxs)(`span`,{className:`truncate`,children:[A(`serviceAppsGrantedTo`),` `,J(e)]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:`rounded-md p-1 text-muted-foreground/70 transition-colors hover:bg-[var(--interaction-hover)] hover:text-rose-600 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,title:A(`serviceAppsRevokeGrant`),"aria-label":A(`serviceAppsRevokeGrant`),children:(0,q.jsx)(k,{className:`h-3 w-3`})})]},`${e.caller.surface}:${J(e)}:${e.actionId}`))]})}function J(e){return e.caller.surface===`panel-app`?e.caller.appId:e.caller.agentId}function Y({app:e,actions:n,actionsOpen:r,grants:i,agents:a,deletePending:s,deleteError:c,dataEntry:l,dataLoading:u,isDiscovering:d,onActionsOpenChange:f,onDiscover:p,onManagePackage:_,onDelete:ee,onResetDelete:v,onRestart:y,onRevoke:b,onGrantAgent:x,grantAgentPending:S}){let[w,E]=(0,K.useState)(!1),[O,j]=(0,K.useState)(!1),[P,I]=(0,K.useState)(!1),[L,R]=(0,K.useState)(!1),z=e.status!==`starting`&&e.status!==`stopped`,W=e.status===`running`||e.status===`failed`,G=e.sourceKind===`package`?e.packageId:void 0,J=se(e),Y=()=>{E(!1),R(!1),v(),j(!0)};return(0,q.jsx)(M,{delayDuration:250,children:(0,q.jsxs)(`section`,{className:`group bg-card transition-colors hover:bg-[var(--interaction-hover)]`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3 px-4 py-3.5`,children:[(0,q.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,q.jsx)(h,{className:`h-4 w-4`})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.title}),(0,q.jsx)(ae,{status:e.status})]}),e.description?(0,q.jsx)(`div`,{className:`mt-1 truncate text-xs leading-5 text-muted-foreground`,children:e.description}):null,e.lastError?(0,q.jsx)(`div`,{className:`mt-1.5 truncate text-xs text-rose-600`,title:e.lastError,children:e.lastError}):null]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[z?(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,disabled:d,className:`inline-flex h-7 items-center gap-1.5 rounded-md bg-foreground px-2.5 text-xs font-medium text-background transition-colors hover:bg-foreground/85 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/40 disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":A(`serviceAppsDiscoverActions`),onClick:()=>p(e.id),children:[d?(0,q.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(te,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:A(`serviceAppsConnect`)})]})}),(0,q.jsx)(B,{side:`bottom`,className:`max-w-56 text-xs`,children:A(`serviceAppsDiscoverActionsHint`)})]}):null,(0,q.jsxs)(U,{open:w,onOpenChange:E,children:[(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{asChild:!0,children:(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:opacity-50`,"aria-label":A(`serviceAppsMoreActions`),disabled:s,children:(0,q.jsx)(C,{className:`h-3.5 w-3.5`})})})}),(0,q.jsx)(B,{side:`bottom`,className:`text-xs`,children:A(`serviceAppsMoreActions`)})]}),(0,q.jsxs)(H,{align:`end`,variant:`menu`,children:[(0,q.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,q.jsx)(X,{disabled:!W,icon:ne,label:A(`serviceAppsDisconnectRuntime`),onClick:()=>{E(!1),y(e.id)}}),G?(0,q.jsx)(X,{icon:t,label:A(`serviceAppsManagePackage`),onClick:()=>{E(!1),_(G)}}):(0,q.jsx)(X,{destructive:!0,disabled:s,icon:k,label:A(`serviceAppsDelete`),onClick:Y}),(0,q.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,q.jsx)(m,{page:g(`service-app`,e.id,e.title),onSelect:()=>E(!1)})]})]})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border/60`,children:[(0,q.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>f(!r),className:`flex min-w-0 flex-1 items-center justify-between gap-2 px-4 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border`,"aria-expanded":r,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{children:A(`serviceAppsActionsSection`)}),(0,q.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:n.length})]}),(0,q.jsx)(T,{className:o(`h-3.5 w-3.5 shrink-0 text-muted-foreground/70 transition-transform`,r&&`rotate-180`)})]}),J.length>0?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>I(e=>!e),className:`flex shrink-0 items-center gap-1 border-l border-border/60 px-3 text-xs text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border`,"aria-expanded":P,children:[(0,q.jsx)(`span`,{children:A(`serviceAppsDetails`)}),(0,q.jsx)(T,{className:o(`h-3.5 w-3.5 transition-transform`,P&&`rotate-180`)})]}):null]}),r?(0,q.jsx)(`div`,{className:`border-t border-border/60 px-4 py-2.5`,children:n.length===0?(0,q.jsx)(`div`,{className:`py-1 text-xs text-muted-foreground`,children:A(`serviceAppsActionsEmpty`)}):(0,q.jsx)(`div`,{className:`divide-y divide-border/50`,children:n.map(e=>(0,q.jsx)(ie,{action:e,grants:i.filter(t=>t.actionId===e.id),agents:a,grantAgentPending:S,onGrantAgent:x,onRevoke:b},e.id))})}):null,P?(0,q.jsx)(ce,{rows:J}):null]}),e.sourceKind===`package`?null:(0,q.jsx)(re,{appId:e.id,appTitle:e.title,dataEntry:l,dataLoading:u,deleteError:c,deletePending:s,open:O,purgeData:L,onDelete:ee,onOpenChange:j,onPurgeDataChange:R})]})})}function ae({status:e}){let t=oe(e),n=t.icon;return(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{asChild:!0,children:(0,q.jsxs)(`span`,{className:o(`inline-flex shrink-0 items-center gap-1 text-xs`,t.className),"aria-label":t.label,children:[(0,q.jsx)(n,{className:o(`h-3 w-3`,t.iconClassName)}),(0,q.jsx)(`span`,{children:t.label})]})}),(0,q.jsx)(B,{side:`bottom`,className:`text-xs`,children:t.tooltip})]})}function oe(e){switch(e){case`running`:return{className:`text-emerald-700`,icon:_,label:A(`serviceAppsStatus_running`),tooltip:A(`serviceAppsStatusHint_running`)};case`starting`:return{className:`text-blue-700`,icon:D,iconClassName:`animate-spin`,label:A(`serviceAppsStatus_starting`),tooltip:A(`serviceAppsStatusHint_starting`)};case`failed`:return{className:`text-rose-700`,icon:y,label:A(`serviceAppsStatus_failed`),tooltip:A(`serviceAppsStatusHint_failed`)};case`stopped`:return{className:`text-muted-foreground`,icon:W,label:A(`serviceAppsStatus_stopped`),tooltip:A(`serviceAppsStatusHint_stopped`)};default:return{className:`text-muted-foreground`,icon:E,label:A(`serviceAppsStatus_idle`),tooltip:A(`serviceAppsStatusHint_idle`)}}}function X({destructive:e=!1,disabled:t=!1,icon:n,label:r,onClick:i}){return(0,q.jsxs)(`button`,{type:`button`,className:o(x,e?S.destructive:`text-foreground ${S.item}`),disabled:t,onClick:i,children:[(0,q.jsx)(n,{className:o(`h-4 w-4 shrink-0`,!e&&`text-muted-foreground`)}),(0,q.jsx)(`span`,{children:r})]})}function se(e){let t=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `);return[{label:A(`serviceAppsCommand`),value:t},{label:A(`serviceAppsCwd`),value:e.cwd},{label:A(`serviceAppsManifest`),value:e.manifestPath},{label:A(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:A(`serviceAppsLastReady`),value:e.lastReadyAt},{label:A(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value)}function ce({rows:e}){return(0,q.jsx)(`div`,{className:`border-t border-border/60 px-4 py-2.5`,children:(0,q.jsx)(`dl`,{className:`grid grid-cols-[4.75rem_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs`,children:e.map(e=>(0,q.jsx)(le,{label:e.label,value:e.value},e.label))})})}function le({label:e,value:t}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground/70`,children:e}),(0,q.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-muted-foreground`,title:t,children:t})]})}var Z=[`service-apps`],Q=[`service-actions`],$=[`service-action-grants`],ue=[`app-data`];function de(){return r({queryKey:Z,queryFn:()=>n.serviceApps.listServiceApps()})}function fe(){return r({queryKey:Q,queryFn:()=>n.serviceApps.listServiceActions()})}function pe(){return r({queryKey:$,queryFn:()=>n.serviceApps.listServiceActionGrants()})}function me(){let e=s();return a({mutationFn:e=>n.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Z}),e.invalidateQueries({queryKey:Q})])}})}function he(){let e=s();return a({mutationFn:e=>n.serviceApps.deleteServiceApp(e.appId,e.purgeData),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Z}),e.invalidateQueries({queryKey:Q}),e.invalidateQueries({queryKey:$}),e.invalidateQueries({queryKey:ue})])}})}function ge(){let e=s();return a({mutationFn:e=>n.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:Z})}})}function _e(){let e=s();return a({mutationFn:e=>n.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Q}),e.invalidateQueries({queryKey:$})])}})}function ve(){let e=s();return a({mutationFn:e=>n.serviceApps.grantAgentServiceActions(e.agentId,e.actionIds),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Q}),e.invalidateQueries({queryKey:$})])}})}function ye({onManagePackage:e,resourceId:t}){let n=de(),r=f(),i=fe(),a=pe(),o=ee(),s=he(),c=me(),l=ge(),u=_e(),d=ve(),[p,m]=(0,K.useState)({}),[g,_]=(0,K.useState)({}),v=()=>{n.refetch(),i.refetch(),a.refetch(),r.refetch()};if(n.isLoading||i.isLoading||a.isLoading)return(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:A(`serviceAppsLoading`)});if(n.isError||i.isError||a.isError){let e=n.error??i.error??a.error;return(0,q.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:A(`serviceAppsLoadFailed`)})}let y=(n.data?.entries??[]).filter(e=>!t||e.id===t);if(t&&!y.length)return(0,q.jsx)(`p`,{role:`alert`,className:`p-4`,children:A(`resourceNotFound`)});let b=n.data?.diagnostics??[],x=i.data?.actions??[],S=a.data?.grants??[],C=e=>{l.mutateAsync(e).then(t=>{m(n=>({...n,[e]:t.actions})),_(t=>({...t,[e]:!0}))})},w=(r.data?.entries??[]).filter(e=>e.source===`workspace-service`&&e.lifecycle===`active`);return(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card text-card-foreground`,children:[(0,q.jsx)(`div`,{className:`flex min-h-12 shrink-0 items-center justify-end border-b border-border/60 px-4 py-2`,children:(0,q.jsx)(M,{delayDuration:250,children:(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,"aria-label":A(`serviceAppsRefresh`),onClick:v,children:(0,q.jsx)(O,{className:`h-3.5 w-3.5`})})}),(0,q.jsx)(B,{side:`bottom`,className:`text-xs`,children:A(`serviceAppsRefresh`)})]})})}),b.length>0?(0,q.jsxs)(`div`,{role:`alert`,className:`mx-3 mt-3 rounded-xl border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive sm:mx-4`,children:[(0,q.jsx)(`div`,{className:`font-medium`,children:A(`serviceAppsLoadFailed`)}),(0,q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:b.map(e=>(0,q.jsxs)(`li`,{className:`break-words`,children:[e.appId,`: `,e.message]},e.stagedPath))})]}):null,y.length===0?(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 py-8 text-center`,children:(0,q.jsxs)(`div`,{className:`w-full max-w-xs`,children:[(0,q.jsx)(`div`,{className:`mx-auto flex h-10 w-10 items-center justify-center rounded-xl bg-muted text-muted-foreground`,children:(0,q.jsx)(h,{className:`h-5 w-5`})}),(0,q.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-foreground`,children:A(`serviceAppsEmptyTitle`)}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:A(`serviceAppsEmptyDescription`)})]})}):(0,q.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3 sm:p-4`,children:(0,q.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border/70 bg-card`,children:y.map(n=>(0,q.jsx)(Y,{app:n,actions:p[n.id]??x.filter(e=>e.appId===n.id),actionsOpen:g[n.id]??!!t,grants:S,agents:o.data?.agents??[],deletePending:s.isPending,deleteError:s.error,dataEntry:w.find(e=>e.appId===n.id),dataLoading:r.isLoading,isDiscovering:l.isPending,onActionsOpenChange:e=>_(t=>({...t,[n.id]:e})),onDiscover:C,onManagePackage:e,onDelete:(e,t,n)=>void s.mutate({appId:e,purgeData:t},{onSuccess:n}),onResetDelete:s.reset,onRestart:e=>void c.mutate(e),onRevoke:e=>void u.mutate({actionId:e.actionId,caller:e.caller}),onGrantAgent:(e,t)=>void d.mutate({actionIds:[e],agentId:t}),grantAgentPending:d.isPending},n.id))})})]})}export{ye as ServiceAppsPanel};
|
|
1
|
+
import{i as e}from"./chunk-DF37yw5_.js";import{S as t}from"./theme-provider-D4rd-tCP.js";import{Lt as n,Qn as r,Yt as i,Zn as a,_n as o,lr as s,ur as c,xr as l}from"./api-CXWxExzS.js";import{$t as u,Ft as d,Nt as f,Pt as p,d as m,en as h,m as g,rn as _,zt as ee}from"./app-presenter-provider-Cx9MwMtb.js";import{t as v}from"./createLucideIcon-C3LSyx-e.js";import{G as y,W as b,g as x,h as S,ut as C,yt as w}from"./context-menu-C6m-WNpl.js";import{z as T}from"./dist-D9h2cWk3.js";import{t as E}from"./circle-dashed-KGwElDWV.js";import{i as D}from"./x-waP-WLuT.js";import{t as O}from"./refresh-cw-DOg2pWGu.js";import{t as k}from"./trash-2-BVQs-0ji.js";import{s as A}from"./i18n-ByVUrt9w.js";import{a as j,d as M,f as N,i as P,l as F,n as I,o as L,r as R,t as z,u as B}from"./dialog-DB_l9LK0.js";import{g as V,h as H,p as U}from"./provider-models-zGsDUBHG.js";var W=v(`CirclePause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),te=v(`Radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),G=v(`ShieldPlus`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9 12h6`,key:`1c52cq`}],[`path`,{d:`M12 9v6`,key:`199k2o`}]]),ne=v(`Unplug`,[[`path`,{d:`m19 5 3-3`,key:`yk6iyv`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z`,key:`1snsnr`}]]),K=e(l(),1),q=c();function re({appId:e,appTitle:t,dataEntry:n,dataLoading:r,deleteError:a,deletePending:o,open:s,purgeData:c,onDelete:l,onOpenChange:u,onPurgeDataChange:f}){let m=(0,K.useRef)(null);(0,K.useEffect)(()=>{a&&m.current?.focus()},[a]);let h=()=>u(!1);return(0,q.jsx)(z,{open:s,onOpenChange:e=>!o&&u(e),children:(0,q.jsxs)(I,{className:`max-w-md`,onEscapeKeyDown:e=>o&&e.preventDefault(),onInteractOutside:e=>o&&e.preventDefault(),children:[(0,q.jsxs)(j,{showClose:!1,children:[(0,q.jsx)(L,{children:A(`serviceAppsDeleteConfirmTitle`)}),(0,q.jsxs)(R,{children:[A(`serviceAppsDeleteConfirmDescription`),` `,t]})]}),(0,q.jsxs)(`div`,{className:`mt-4 grid gap-2`,children:[(0,q.jsx)(d,{checked:!c,description:A(`serviceAppsKeepDataDescription`),label:A(`appPackagesKeepData`),onClick:()=>f(!1)}),(0,q.jsx)(d,{checked:c,destructive:!0,disabled:!n||r,description:A(`serviceAppsDeleteDataDescription`),label:A(`appPackagesDeleteData`),onClick:()=>f(!0)})]}),n?(0,q.jsx)(`div`,{className:`mt-3`,children:(0,q.jsx)(p,{storage:n.storage,usage:n.usage})}):(0,q.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-muted-foreground`,children:A(r?`appPackagesLoading`:`serviceAppsDataUnavailable`)}),a?(0,q.jsx)(`p`,{ref:m,role:`alert`,tabIndex:-1,className:`mt-3 text-xs text-destructive`,children:a instanceof Error?a.message:A(`appPackagesActionFailed`)}):null,(0,q.jsxs)(P,{className:`mt-5 gap-2 sm:gap-0`,children:[(0,q.jsx)(i,{autoFocus:!0,type:`button`,variant:`outline`,disabled:o,onClick:h,children:A(`cancel`)}),(0,q.jsxs)(i,{type:`button`,variant:c?`destructive`:`default`,disabled:o||c&&!n,onClick:()=>l(e,c,h),children:[o?(0,q.jsx)(D,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):null,A(c?`appDataDeletePermanently`:`serviceAppsDelete`)]})]})]})})}function ie({action:e,grants:t,agents:n,grantAgentPending:r,onGrantAgent:i,onRevoke:a}){let[o,s]=(0,K.useState)(!1),c=new Set(t.flatMap(e=>e.caller.surface===`agent`?[e.caller.agentId]:[])),l=n.filter(e=>!c.has(e.id));return(0,q.jsxs)(`div`,{className:`py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center text-muted-foreground`,children:(0,q.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`truncate text-xs font-medium text-foreground`,children:e.title??e.name}),e.description?(0,q.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:e.description}):null]})]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[e.runtimeState?(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:A(`serviceAppsRuntimeState_${e.runtimeState}`)}):null,(0,q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.risk}),(0,q.jsxs)(U,{open:o,onOpenChange:s,children:[(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,disabled:r||l.length===0,className:`ml-1 rounded-md p-1 text-muted-foreground/70 transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:cursor-not-allowed disabled:opacity-40`,title:A(`serviceAppsGrantToAgent`),"aria-label":A(`serviceAppsGrantToAgent`),children:(0,q.jsx)(G,{className:`h-3.5 w-3.5`})})}),(0,q.jsxs)(H,{align:`end`,variant:`menu`,children:[(0,q.jsx)(`div`,{className:`px-2 py-1.5 text-[11px] font-medium text-muted-foreground`,children:A(`serviceAppsGrantToAgent`)}),l.map(t=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{i(e.id,t.id),s(!1)},className:`${x} text-foreground ${S.item}`,children:[(0,q.jsx)(w,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`min-w-0 truncate`,children:t.displayName?.trim()||t.id})]},t.id))]})]})]})]}),t.map(e=>(0,q.jsxs)(`div`,{className:`mt-1.5 flex items-center justify-between gap-2 pl-8`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground`,children:[(0,q.jsx)(u,{className:`h-3 w-3 shrink-0 text-emerald-500`}),(0,q.jsxs)(`span`,{className:`truncate`,children:[A(`serviceAppsGrantedTo`),` `,J(e)]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>a(e),className:`rounded-md p-1 text-muted-foreground/70 transition-colors hover:bg-[var(--interaction-hover)] hover:text-rose-600 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,title:A(`serviceAppsRevokeGrant`),"aria-label":A(`serviceAppsRevokeGrant`),children:(0,q.jsx)(k,{className:`h-3 w-3`})})]},`${e.caller.surface}:${J(e)}:${e.actionId}`))]})}function J(e){return e.caller.surface===`panel-app`?e.caller.appId:e.caller.agentId}function Y({app:e,actions:n,actionsOpen:r,grants:i,agents:a,deletePending:s,deleteError:c,dataEntry:l,dataLoading:u,isDiscovering:d,onActionsOpenChange:f,onDiscover:p,onManagePackage:_,onDelete:ee,onResetDelete:v,onRestart:y,onRevoke:b,onGrantAgent:x,grantAgentPending:S}){let[w,E]=(0,K.useState)(!1),[O,j]=(0,K.useState)(!1),[P,I]=(0,K.useState)(!1),[L,R]=(0,K.useState)(!1),z=e.status!==`starting`&&e.status!==`stopped`,W=e.status===`running`||e.status===`failed`,G=e.sourceKind===`package`?e.packageId:void 0,J=se(e),Y=()=>{E(!1),R(!1),v(),j(!0)};return(0,q.jsx)(M,{delayDuration:250,children:(0,q.jsxs)(`section`,{className:`group bg-card transition-colors hover:bg-[var(--interaction-hover)]`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3 px-4 py-3.5`,children:[(0,q.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,q.jsx)(h,{className:`h-4 w-4`})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.title}),(0,q.jsx)(ae,{status:e.status})]}),e.description?(0,q.jsx)(`div`,{className:`mt-1 truncate text-xs leading-5 text-muted-foreground`,children:e.description}):null,e.lastError?(0,q.jsx)(`div`,{className:`mt-1.5 truncate text-xs text-rose-600`,title:e.lastError,children:e.lastError}):null]}),(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[z?(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,disabled:d,className:`inline-flex h-7 items-center gap-1.5 rounded-md bg-foreground px-2.5 text-xs font-medium text-background transition-colors hover:bg-foreground/85 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground/40 disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":A(`serviceAppsDiscoverActions`),onClick:()=>p(e.id),children:[d?(0,q.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}):(0,q.jsx)(te,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:A(`serviceAppsConnect`)})]})}),(0,q.jsx)(B,{side:`bottom`,className:`max-w-56 text-xs`,children:A(`serviceAppsDiscoverActionsHint`)})]}):null,(0,q.jsxs)(U,{open:w,onOpenChange:E,children:[(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{asChild:!0,children:(0,q.jsx)(V,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border disabled:opacity-50`,"aria-label":A(`serviceAppsMoreActions`),disabled:s,children:(0,q.jsx)(C,{className:`h-3.5 w-3.5`})})})}),(0,q.jsx)(B,{side:`bottom`,className:`text-xs`,children:A(`serviceAppsMoreActions`)})]}),(0,q.jsxs)(H,{align:`end`,variant:`menu`,children:[(0,q.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,q.jsx)(X,{disabled:!W,icon:ne,label:A(`serviceAppsDisconnectRuntime`),onClick:()=>{E(!1),y(e.id)}}),G?(0,q.jsx)(X,{icon:t,label:A(`serviceAppsManagePackage`),onClick:()=>{E(!1),_(G)}}):(0,q.jsx)(X,{destructive:!0,disabled:s,icon:k,label:A(`serviceAppsDelete`),onClick:Y}),(0,q.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,q.jsx)(m,{page:g(`service-app`,e.id,e.title),onSelect:()=>E(!1)})]})]})]})]}),(0,q.jsxs)(`div`,{className:`border-t border-border/60`,children:[(0,q.jsxs)(`div`,{className:`flex items-stretch`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>f(!r),className:`flex min-w-0 flex-1 items-center justify-between gap-2 px-4 py-2 text-left text-xs text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border`,"aria-expanded":r,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,q.jsx)(`span`,{children:A(`serviceAppsActionsSection`)}),(0,q.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:n.length})]}),(0,q.jsx)(T,{className:o(`h-3.5 w-3.5 shrink-0 text-muted-foreground/70 transition-transform`,r&&`rotate-180`)})]}),J.length>0?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>I(e=>!e),className:`flex shrink-0 items-center gap-1 border-l border-border/60 px-3 text-xs text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border`,"aria-expanded":P,children:[(0,q.jsx)(`span`,{children:A(`serviceAppsDetails`)}),(0,q.jsx)(T,{className:o(`h-3.5 w-3.5 transition-transform`,P&&`rotate-180`)})]}):null]}),r?(0,q.jsx)(`div`,{className:`border-t border-border/60 px-4 py-2.5`,children:n.length===0?(0,q.jsx)(`div`,{className:`py-1 text-xs text-muted-foreground`,children:A(`serviceAppsActionsEmpty`)}):(0,q.jsx)(`div`,{className:`divide-y divide-border/50`,children:n.map(e=>(0,q.jsx)(ie,{action:e,grants:i.filter(t=>t.actionId===e.id),agents:a,grantAgentPending:S,onGrantAgent:x,onRevoke:b},e.id))})}):null,P?(0,q.jsx)(ce,{rows:J}):null]}),e.sourceKind===`package`?null:(0,q.jsx)(re,{appId:e.id,appTitle:e.title,dataEntry:l,dataLoading:u,deleteError:c,deletePending:s,open:O,purgeData:L,onDelete:ee,onOpenChange:j,onPurgeDataChange:R})]})})}function ae({status:e}){let t=oe(e),n=t.icon;return(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{asChild:!0,children:(0,q.jsxs)(`span`,{className:o(`inline-flex shrink-0 items-center gap-1 text-xs`,t.className),"aria-label":t.label,children:[(0,q.jsx)(n,{className:o(`h-3 w-3`,t.iconClassName)}),(0,q.jsx)(`span`,{children:t.label})]})}),(0,q.jsx)(B,{side:`bottom`,className:`text-xs`,children:t.tooltip})]})}function oe(e){switch(e){case`running`:return{className:`text-emerald-700`,icon:_,label:A(`serviceAppsStatus_running`),tooltip:A(`serviceAppsStatusHint_running`)};case`starting`:return{className:`text-blue-700`,icon:D,iconClassName:`animate-spin`,label:A(`serviceAppsStatus_starting`),tooltip:A(`serviceAppsStatusHint_starting`)};case`failed`:return{className:`text-rose-700`,icon:y,label:A(`serviceAppsStatus_failed`),tooltip:A(`serviceAppsStatusHint_failed`)};case`stopped`:return{className:`text-muted-foreground`,icon:W,label:A(`serviceAppsStatus_stopped`),tooltip:A(`serviceAppsStatusHint_stopped`)};default:return{className:`text-muted-foreground`,icon:E,label:A(`serviceAppsStatus_idle`),tooltip:A(`serviceAppsStatusHint_idle`)}}}function X({destructive:e=!1,disabled:t=!1,icon:n,label:r,onClick:i}){return(0,q.jsxs)(`button`,{type:`button`,className:o(x,e?S.destructive:`text-foreground ${S.item}`),disabled:t,onClick:i,children:[(0,q.jsx)(n,{className:o(`h-4 w-4 shrink-0`,!e&&`text-muted-foreground`)}),(0,q.jsx)(`span`,{children:r})]})}function se(e){let t=[e.command,...e.args??[]].filter(e=>!!e?.trim()).join(` `);return[{label:A(`serviceAppsCommand`),value:t},{label:A(`serviceAppsCwd`),value:e.cwd},{label:A(`serviceAppsManifest`),value:e.manifestPath},{label:A(`serviceAppsLastStarted`),value:e.lastStartedAt},{label:A(`serviceAppsLastReady`),value:e.lastReadyAt},{label:A(`serviceAppsLastFailed`),value:e.lastFailedAt}].filter(e=>e.value)}function ce({rows:e}){return(0,q.jsx)(`div`,{className:`border-t border-border/60 px-4 py-2.5`,children:(0,q.jsx)(`dl`,{className:`grid grid-cols-[4.75rem_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs`,children:e.map(e=>(0,q.jsx)(le,{label:e.label,value:e.value},e.label))})})}function le({label:e,value:t}){return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground/70`,children:e}),(0,q.jsx)(`dd`,{className:`min-w-0 truncate font-mono text-muted-foreground`,title:t,children:t})]})}var Z=[`service-apps`],Q=[`service-actions`],$=[`service-action-grants`],ue=[`app-data`];function de(){return r({queryKey:Z,queryFn:()=>n.serviceApps.listServiceApps()})}function fe(){return r({queryKey:Q,queryFn:()=>n.serviceApps.listServiceActions()})}function pe(){return r({queryKey:$,queryFn:()=>n.serviceApps.listServiceActionGrants()})}function me(){let e=s();return a({mutationFn:e=>n.serviceApps.restartServiceApp(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Z}),e.invalidateQueries({queryKey:Q})])}})}function he(){let e=s();return a({mutationFn:e=>n.serviceApps.deleteServiceApp(e.appId,e.purgeData),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Z}),e.invalidateQueries({queryKey:Q}),e.invalidateQueries({queryKey:$}),e.invalidateQueries({queryKey:ue})])}})}function ge(){let e=s();return a({mutationFn:e=>n.serviceApps.discoverServiceAppActions(e),onSuccess:async()=>{await e.invalidateQueries({queryKey:Z})}})}function _e(){let e=s();return a({mutationFn:e=>n.serviceApps.revokeServiceActionGrant(e),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Q}),e.invalidateQueries({queryKey:$})])}})}function ve(){let e=s();return a({mutationFn:e=>n.serviceApps.grantAgentServiceActions(e.agentId,e.actionIds),onSuccess:async()=>{await Promise.all([e.invalidateQueries({queryKey:Q}),e.invalidateQueries({queryKey:$})])}})}function ye({onManagePackage:e,resourceId:t}){let n=de(),r=f(),i=fe(),a=pe(),o=ee(),s=he(),c=me(),l=ge(),u=_e(),d=ve(),[p,m]=(0,K.useState)({}),[g,_]=(0,K.useState)({}),v=()=>{n.refetch(),i.refetch(),a.refetch(),r.refetch()};if(n.isLoading||i.isLoading||a.isLoading)return(0,q.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:A(`serviceAppsLoading`)});if(n.isError||i.isError||a.isError){let e=n.error??i.error??a.error;return(0,q.jsx)(`div`,{className:`p-4 text-sm text-rose-600`,children:e instanceof Error?e.message:A(`serviceAppsLoadFailed`)})}let y=(n.data?.entries??[]).filter(e=>!t||e.id===t);if(t&&!y.length)return(0,q.jsx)(`p`,{role:`alert`,className:`p-4`,children:A(`resourceNotFound`)});let b=n.data?.diagnostics??[],x=i.data?.actions??[],S=a.data?.grants??[],C=e=>{l.mutateAsync(e).then(t=>{m(n=>({...n,[e]:t.actions})),_(t=>({...t,[e]:!0}))})},w=(r.data?.entries??[]).filter(e=>e.source===`workspace-service`&&e.lifecycle===`active`);return(0,q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-card text-card-foreground`,children:[(0,q.jsx)(`div`,{className:`flex min-h-12 shrink-0 items-center justify-end border-b border-border/60 px-4 py-2`,children:(0,q.jsx)(M,{delayDuration:250,children:(0,q.jsxs)(F,{children:[(0,q.jsx)(N,{asChild:!0,children:(0,q.jsx)(`button`,{type:`button`,className:`rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-[var(--interaction-hover)] hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border`,"aria-label":A(`serviceAppsRefresh`),onClick:v,children:(0,q.jsx)(O,{className:`h-3.5 w-3.5`})})}),(0,q.jsx)(B,{side:`bottom`,className:`text-xs`,children:A(`serviceAppsRefresh`)})]})})}),b.length>0?(0,q.jsxs)(`div`,{role:`alert`,className:`mx-3 mt-3 rounded-xl border border-destructive/20 bg-destructive/5 px-3 py-2.5 text-xs text-destructive sm:mx-4`,children:[(0,q.jsx)(`div`,{className:`font-medium`,children:A(`serviceAppsLoadFailed`)}),(0,q.jsx)(`ul`,{className:`mt-1 space-y-1`,children:b.map(e=>(0,q.jsxs)(`li`,{className:`break-words`,children:[e.appId,`: `,e.message]},e.stagedPath))})]}):null,y.length===0?(0,q.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-6 py-8 text-center`,children:(0,q.jsxs)(`div`,{className:`w-full max-w-xs`,children:[(0,q.jsx)(`div`,{className:`mx-auto flex h-10 w-10 items-center justify-center rounded-xl bg-muted text-muted-foreground`,children:(0,q.jsx)(h,{className:`h-5 w-5`})}),(0,q.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-foreground`,children:A(`serviceAppsEmptyTitle`)}),(0,q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-muted-foreground`,children:A(`serviceAppsEmptyDescription`)})]})}):(0,q.jsx)(`div`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto p-3 sm:p-4`,children:(0,q.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-border/70 bg-card`,children:y.map(n=>(0,q.jsx)(Y,{app:n,actions:p[n.id]??x.filter(e=>e.appId===n.id),actionsOpen:g[n.id]??!!t,grants:S,agents:o.data?.agents??[],deletePending:s.isPending,deleteError:s.error,dataEntry:w.find(e=>e.appId===n.id),dataLoading:r.isLoading,isDiscovering:l.isPending,onActionsOpenChange:e=>_(t=>({...t,[n.id]:e})),onDiscover:C,onManagePackage:e,onDelete:(e,t,n)=>void s.mutate({appId:e,purgeData:t},{onSuccess:n}),onResetDelete:s.reset,onRestart:e=>void c.mutate(e),onRevoke:e=>void u.mutate({actionId:e.actionId,caller:e.caller}),onGrantAgent:(e,t)=>void d.mutate({actionIds:[e],agentId:t}),grantAgentPending:d.isPending},n.id))})})]})}export{ye as ServiceAppsPanel};
|