@nextclaw/ui 0.12.20-beta.0 → 0.12.20-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 +12 -0
- package/dist/assets/api-BcqDx0tm.js +15 -0
- package/dist/assets/app-manager-provider-DVYBjif-.js +1 -0
- package/dist/assets/{app-navigation.config-BORqHkbN.js → app-navigation.config-CMoWvFEI.js} +1 -1
- package/dist/assets/{channels-list-page-sISO_4Yj.js → channels-list-page-CsoI4OJm.js} +2 -2
- package/dist/assets/{chat-ChCu7LQD.js → chat-CA3aRmhx.js} +6 -6
- package/dist/assets/chat-page-gdSN6Pr6.js +1 -0
- package/dist/assets/chunk-JZWAC4HX-u4uYphxM.js +3 -0
- package/dist/assets/{desktop-update-config-BfJ5iSeY.js → desktop-update-config-CD6-2PfI.js} +1 -1
- package/dist/assets/{dialog-B-CXiFPZ.js → dialog-csshWetU.js} +1 -1
- package/dist/assets/{dist-DYVfg3q5.js → dist-Bl94Ahwx.js} +1 -1
- package/dist/assets/{es2015-BXroVnPi.js → es2015-JCM5-KtW.js} +1 -1
- package/dist/assets/index-BTDFuKka.js +2 -0
- package/dist/assets/marketplace-page-DJGDpTAo.js +1 -0
- package/dist/assets/{marketplace-page-C9oZ01rM.js → marketplace-page-DxlxHCFm.js} +2 -2
- package/dist/assets/{mcp-marketplace-page-DuEixgSs.js → mcp-marketplace-page-5UjYRWOR.js} +2 -2
- package/dist/assets/mcp-marketplace-page-C1XaHZZO.js +1 -0
- package/dist/assets/{model-config-mfhqEZBG.js → model-config-PccJ9XyH.js} +1 -1
- package/dist/assets/{notice-card-CozHB03G.js → notice-card-CCgk6FvF.js} +1 -1
- package/dist/assets/{popover-CPUPma-w.js → popover-YAsxDBhY.js} +1 -1
- package/dist/assets/{provider-scoped-model-input-CL9sti2I.js → provider-scoped-model-input-CzpF7cug.js} +1 -1
- package/dist/assets/{providers-list-HPmL2akJ.js → providers-list-8qDMER8o.js} +1 -1
- package/dist/assets/remote-D4TtLPAp.js +1 -0
- package/dist/assets/runtime-config-page-D-4c5H5z.js +1 -0
- package/dist/assets/{search-config-Bcnk9VlL.js → search-config-D3a65l3r.js} +1 -1
- package/dist/assets/{secrets-config-Dde-5Y1w.js → secrets-config-CoMlR_7i.js} +2 -2
- package/dist/assets/{select-BELPuXLW.js → select-DIZrwsKU.js} +1 -1
- package/dist/assets/{sessions-config-page-CG49_0Z6.js → sessions-config-page-Cc0TJStn.js} +2 -2
- package/dist/assets/{setting-row-D5DtT6Ny.js → setting-row-DiQyrE81.js} +1 -1
- package/dist/assets/{tag-chip-D9BWWgYg.js → tag-chip-C3wDBe_-.js} +1 -1
- package/dist/assets/{theme-provider-DeBrTglS.js → theme-provider-aOmrJ9J6.js} +1 -1
- package/dist/assets/{tooltip-CI0rpNee.js → tooltip-Dq5Xehpk.js} +1 -1
- package/dist/assets/use-config-BQJjq1mP.js +1 -0
- package/dist/assets/{use-confirm-dialog-hbynwWf2.js → use-confirm-dialog-DBoV5n5P.js} +1 -1
- package/dist/assets/{use-infinite-scroll-loader-Cw5qQr3-.js → use-infinite-scroll-loader-JAicqVC5.js} +1 -1
- package/dist/assets/{use-viewport-layout-CWHVDC6z.js → use-viewport-layout-BX3XqzJ4.js} +1 -1
- package/dist/index.html +16 -16
- package/package.json +8 -6
- package/src/app/hooks/use-realtime-query-bridge.ts +5 -5
- package/src/features/channels/components/config/channel-form.tsx +3 -3
- package/src/features/chat/hooks/use-ncp-chat-page-data.ts +7 -6
- package/src/features/chat/pages/ncp-chat-page.test.ts +22 -8
- package/src/features/chat/utils/chat-session-preference-governance.utils.test.tsx +114 -0
- package/src/features/chat/utils/chat-session-preference-governance.utils.ts +30 -36
- package/src/shared/lib/api/index.ts +12 -12
- package/src/shared/lib/api/ncp-session.test.ts +17 -18
- package/src/shared/lib/api/raw-client.utils.ts +3 -126
- package/src/shared/lib/api/services/agents.service.ts +18 -0
- package/src/shared/lib/api/services/channel-auth.service.ts +21 -0
- package/src/shared/lib/api/{client.ts → services/client.service.ts} +45 -1
- package/src/shared/lib/api/services/config.service.ts +171 -0
- package/src/shared/lib/api/services/marketplace.service.ts +66 -0
- package/src/shared/lib/api/services/mcp-marketplace.service.ts +70 -0
- package/src/shared/lib/api/services/ncp-attachments.service.ts +14 -0
- package/src/shared/lib/api/services/ncp-session.service.ts +39 -0
- package/src/shared/lib/api/services/remote.service.ts +50 -0
- package/src/shared/lib/api/services/runtime-control.service.ts +18 -0
- package/src/shared/lib/api/services/runtime-update.service.ts +26 -0
- package/src/shared/lib/api/services/server-path.service.ts +16 -0
- package/src/shared/lib/transport/index.ts +1 -0
- package/src/shared/lib/transport/local-transport.service.ts +24 -4
- package/src/shared/lib/transport/remote-transport.service.ts +1 -1
- package/src/shared/lib/transport/request-raw-api-response.utils.ts +133 -0
- package/src/shared/lib/transport/transport.types.ts +8 -2
- package/dist/assets/api-C412zuay.js +0 -15
- package/dist/assets/app-manager-provider-Cm-KiZZG.js +0 -1
- package/dist/assets/chat-page-BCaNZJGT.js +0 -1
- package/dist/assets/chunk-JZWAC4HX-DvbcIVPf.js +0 -3
- package/dist/assets/index-CqPDhosM.js +0 -2
- package/dist/assets/marketplace-page-C8uaWkfd.js +0 -1
- package/dist/assets/mcp-marketplace-page-rNqr6ZpD.js +0 -1
- package/dist/assets/remote-oDlAdgVA.js +0 -1
- package/dist/assets/runtime-config-page-BCshTAAE.js +0 -1
- package/dist/assets/use-config-CrWZ_TSF.js +0 -1
- package/src/shared/lib/api/agents.ts +0 -34
- package/src/shared/lib/api/channel-auth.ts +0 -35
- package/src/shared/lib/api/config.ts +0 -362
- package/src/shared/lib/api/marketplace.ts +0 -156
- package/src/shared/lib/api/mcp-marketplace.ts +0 -138
- package/src/shared/lib/api/ncp-attachments.ts +0 -41
- package/src/shared/lib/api/ncp-session.ts +0 -78
- package/src/shared/lib/api/remote.ts +0 -86
- package/src/shared/lib/api/runtime-control.ts +0 -34
- package/src/shared/lib/api/runtime-update.service.ts +0 -50
- package/src/shared/lib/api/server-path.ts +0 -46
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,n as r,p as i}from"./i18n-C5Mibli1.js";import{At as a,Ct as o,Dt as s,Et as c,It as l,Mt as u,Ot as d,Pt as f,Rt as p,St as m,Tt as h,a as g,c as _,d as v,ft as y,i as b,jt as x,kt as ee,l as te,o as S,s as C,u as w,wt as T}from"./api-C412zuay.js";import{a as ne,n as re,o as ie,r as ae,t as E}from"./dialog-B-CXiFPZ.js";import{t as D}from"./createLucideIcon-BZkY6emz.js";import{t as oe}from"./key-round-CnI1mc9F.js";import{t as O}from"./refresh-ccw-Bii4w8aB.js";import{t as k}from"./notice-card-CozHB03G.js";import{t as A}from"./status-dot-Dv_hiUVa.js";var se=D(`Laptop`,[[`path`,{d:`M20 16V7a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v9m16 0H4m16 0 1.28 2.55a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45L4 16`,key:`tarvll`}]]),j=D(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),M=D(`SquareArrowOutUpRight`,[[`path`,{d:`M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6`,key:`y09zxi`}],[`path`,{d:`m21 3-9 9`,key:`mpx6sq`}],[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}]]);function N(){return p({queryKey:L,queryFn:S,staleTime:5e3,refetchOnWindowFocus:!0})}var P=e(n(),1),F=i();function I(e){let{label:t,muted:n,value:r}=e;return(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,F.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,F.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function ce(){let e=$(),n=N(),i=n.data,a=U(e=>e.actionLabel),l=(0,P.useMemo)(()=>q(i),[i]),f=!!a,p=i?.runtime?.deviceName?.trim()||i?.settings.deviceName?.trim()||t(`remoteDeviceNameAuto`),m=!!(i?.account.loggedIn&&H(i)),{hero:g,issueHint:_}=l;return(0,P.useEffect)(()=>{e.remoteAccessManager.syncStatus(i)},[e,i]),n.isLoading&&!i?(0,F.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`remoteLoading`)}):(0,F.jsxs)(ee,{className:`space-y-6`,children:[(0,F.jsx)(d,{title:t(`remotePageTitle`),description:t(`remotePageDescription`)}),(0,F.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,F.jsxs)(o,{children:[(0,F.jsxs)(c,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,F.jsx)(s,{children:g.title}),(0,F.jsx)(A,{status:g.badgeStatus,label:g.badgeLabel})]}),(0,F.jsx)(h,{children:g.description})]}),(0,F.jsxs)(T,{className:`space-y-5`,children:[(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(I,{label:t(`remoteSignedInAccount`),value:i?.account.email}),(0,F.jsx)(I,{label:t(`remoteDeviceName`),value:p}),(0,F.jsx)(I,{label:t(`remoteConnectionStatus`),value:g.badgeLabel}),(0,F.jsx)(I,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[l.primaryAction?(0,F.jsxs)(u,{onClick:()=>{if(l.primaryAction?.kind===`reauthorize`){e.remoteAccessManager.reauthorizeRemoteAccess(i);return}if(l.primaryAction?.kind===`repair`){e.remoteAccessManager.repairRemoteAccess(i);return}e.remoteAccessManager.enableRemoteAccess(i)},disabled:f,children:[l.primaryAction.showRefreshIcon?(0,F.jsx)(O,{className:`mr-2 h-4 w-4`}):null,a||l.primaryAction.label]}):null,(0,F.jsxs)(u,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:f||!m,children:[(0,F.jsx)(M,{className:`mr-2 h-4 w-4`}),t(`remoteOpenDeviceList`)]}),i?.settings.enabled?(0,F.jsx)(u,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(i),disabled:f,children:t(`remoteDisable`)}):null]}),l.shouldShowIssueHint&&_?(0,F.jsx)(k,{tone:`warning`,title:_.title,description:_.body}):null,(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`remoteOpenWebHint`)})]})]}),(0,F.jsxs)(o,{children:[(0,F.jsxs)(c,{children:[(0,F.jsxs)(s,{className:`flex items-center gap-2`,children:[(0,F.jsx)(se,{className:`h-4 w-4 text-primary`}),t(`remoteDeviceSectionTitle`)]}),(0,F.jsx)(h,{children:t(`remoteDeviceSectionDescription`)})]}),(0,F.jsxs)(T,{className:`space-y-5`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsx)(A,{status:i?.account.loggedIn?`ready`:`inactive`,label:i?.account.loggedIn?t(`remoteAccountConnected`):t(`remoteAccountNotConnected`)}),(0,F.jsx)(A,{status:i?.settings.enabled?`active`:`inactive`,label:i?.settings.enabled?t(`remoteEnabled`):t(`remoteStateDisabled`)}),(0,F.jsx)(A,{status:i?.service.running?`active`:`inactive`,label:i?.service.running?t(`remoteServiceRunning`):t(`remoteServiceStopped`)})]}),(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(I,{label:t(`remoteDeviceName`),value:p}),(0,F.jsx)(I,{label:t(`remoteConnectionStatus`),value:g.badgeLabel}),(0,F.jsx)(I,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,F.jsx)(k,{tone:`neutral`,borderStyle:`dashed`,description:i?.account.loggedIn?t(`remoteOpenWebHint`):t(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var L=[`remote-status`],le=`https://platform.nextclaw.io`,ue=`https://nextclaw-platform-console.pages.dev`,R=async()=>await f.fetchQuery({queryKey:L,queryFn:S,staleTime:5e3}),z=async()=>(await f.invalidateQueries({queryKey:L}),await R()),B=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function V(e){let t=e?.trim();if(!t)return;let n;try{n=new URL(t)}catch{return}if(n.hostname===`platform.nextclaw.io`||n.hostname===`nextclaw-platform-console.pages.dev`)return n.origin;if(n.hostname===`ai-gateway-api.nextclaw.io`)return le;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return ue}var H=e=>V(e?.account.apiBase)||V(e?.settings.platformApiBase)||V(e?.platformBase)||V(e?.account.platformBase)||void 0,U=m(e=>({enabled:!1,deviceName:``,platformApiBase:``,advancedOpen:!1,draftTouched:!1,actionLabel:null,doctor:null,setEnabled:t=>e({enabled:t,draftTouched:!0}),setDeviceName:t=>e({deviceName:t,draftTouched:!0}),setPlatformApiBase:t=>e({platformApiBase:t,draftTouched:!0}),setAdvancedOpen:t=>e({advancedOpen:t}),hydrateDraft:({enabled:t,deviceName:n,platformApiBase:r})=>e({enabled:t,deviceName:n,platformApiBase:r,draftTouched:!1}),beginAction:t=>e({actionLabel:t}),finishAction:()=>e({actionLabel:null}),setDoctor:t=>e({doctor:t})})),W=class{constructor(){this.accountManager=null,this.bindAccountManager=e=>{this.accountManager=e},this.syncStatus=e=>{if(!e)return;let t=U.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{U.getState().setEnabled(e)},this.setDeviceName=e=>{U.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{U.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{U.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await z(),n=U.getState();if(!t.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`},apiBase:n.platformApiBase});return}await this.applyEnabledState(!0,t)},this.disableRemoteAccess=async e=>{let t=e??await z();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let n=e??await z();if(!n.account.loggedIn){await this.accountManager?.ensureSignedIn({pendingAction:{type:`enable-remote`}});return}let r=n.service.running?`restart`:`start`;await this.runManagedAction({actionLabel:t(r===`restart`?`remoteActionRestarting`:`remoteActionStarting`),job:async()=>{await b(r);let e=await z();this.hydrateDraftFromStatus(e)},successMessage:t(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await z();await this.accountManager?.startBrowserSignIn({status:t,apiBase:U.getState().platformApiBase,pendingAction:{type:`repair-remote`}})},this.saveAdvancedSettings=async e=>{let n=e??await z(),r=U.getState();await this.runManagedAction({actionLabel:t(`remoteActionSavingAdvanced`),job:async()=>{await v({enabled:r.enabled,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let e=await z();this.hydrateDraftFromStatus(e)},successMessage:n.settings.enabled===r.enabled?t(`remoteSettingsSaved`):t(`remoteAdvancedSaved`)})},this.runDoctor=async()=>{await this.runManagedAction({actionLabel:t(`remoteDoctorRunning`),job:async()=>{let e=await g();U.getState().setDoctor(e)},successMessage:t(`remoteDoctorCompleted`)})},this.startService=async()=>{await this.runServiceAction(`start`,t(`remoteActionStarting`))},this.restartService=async()=>{await this.runServiceAction(`restart`,t(`remoteActionRestarting`))},this.stopService=async()=>{await this.runServiceAction(`stop`,t(`remoteActionStopping`))},this.resumePendingActionAfterSignIn=async(e,t)=>{if(e){if(e.type===`enable-remote`){await this.applyEnabledState(!0,t);return}e.type===`repair-remote`&&await this.repairRemoteAccess(t)}},this.applyEnabledState=async(e,n)=>{let r=U.getState();await this.runManagedAction({actionLabel:t(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await v({enabled:e,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let t=await z();this.hydrateDraftFromStatus(t),e?await b(t.service.running?`restart`:`start`):n.service.running&&await b(`restart`);let i=await z();this.hydrateDraftFromStatus(i)},successMessage:t(e?`remoteEnabledReady`:`remoteDisabledDone`)})},this.runServiceAction=async(e,t)=>{await this.runManagedAction({actionLabel:t,job:async()=>{let t=await b(e),n=await z();this.hydrateDraftFromStatus(n),l.success(t.message)}})},this.hydrateDraftFromStatus=e=>{U.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{U.getState().beginAction(e.actionLabel);try{await e.job(),e.successMessage&&l.success(e.successMessage)}catch(e){let n=e instanceof Error?e.message:t(`error`);throw l.error(n),e}finally{U.getState().finishAction()}}}},de=[/invalid or expired token/i,/missing bearer token/i,/token expired/i,/token is invalid/i,/run "nextclaw login"/i,/browser sign-in again/i];function G(e){return e?.runtime?.lastError?.trim()||``}function fe(e){let n=t(`remoteStatusIssueDetailGeneric`),r=G(e);return r?`${n} (${r})`:n}function K(e){if(!e?.settings.enabled)return!1;let t=G(e);return de.some(e=>e.test(t))}function q(e){return K(e)?{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateReauthorizationRequired`),title:t(`remoteStatusReauthorizationTitle`),description:t(`remoteStatusReauthorizationDescription`)},primaryAction:{kind:`reauthorize`,label:t(`remoteReauthorizeNow`),showRefreshIcon:!1},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusReauthorizationHint`)},shouldShowIssueHint:!0,requiresReauthorization:!0}:e?.account.loggedIn?e.settings.enabled?e.service.running?e.runtime?.state===`connected`?{hero:{badgeStatus:`ready`,badgeLabel:t(`statusReady`),title:t(`remoteStatusReadyTitle`),description:t(`remoteStatusReadyDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:e.runtime?.state===`connecting`?{hero:{badgeStatus:`active`,badgeLabel:t(`connecting`),title:t(`remoteStatusConnectingTitle`),description:t(`remoteStatusConnectingDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteStateDisconnected`),title:t(`remoteStatusIssueTitle`),description:t(`remoteStatusIssueDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:fe(e)},shouldShowIssueHint:!!(e.settings.enabled&&e.account.loggedIn),requiresReauthorization:!1}:{hero:{badgeStatus:`warning`,badgeLabel:t(`remoteServiceStopped`),title:t(`remoteStatusNeedsServiceTitle`),description:t(`remoteStatusNeedsServiceDescription`)},primaryAction:{kind:`repair`,label:t(`remoteReconnectNow`),showRefreshIcon:!0},issueHint:{title:t(`remoteStatusRecoveryTitle`),body:t(`remoteStatusIssueDetailServiceStopped`)},shouldShowIssueHint:!0,requiresReauthorization:!1}:{hero:{badgeStatus:`inactive`,badgeLabel:t(`statusInactive`),title:t(`remoteStatusNeedsEnable`),description:t(`remoteStatusNeedsEnableDescription`)},primaryAction:{kind:`enable`,label:t(`remoteEnableNow`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}:{hero:{badgeStatus:`setup`,badgeLabel:t(`statusSetup`),title:t(`remoteStatusNeedsSignIn`),description:t(`remoteStatusNeedsSignInDescription`)},primaryAction:{kind:`sign-in-enable`,label:t(`remoteSignInAndEnable`),showRefreshIcon:!1},issueHint:null,shouldShowIssueHint:!1,requiresReauthorization:!1}}var J=m(e=>({panelOpen:!1,authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500,pendingAction:null,openPanel:()=>e({panelOpen:!0}),closePanel:()=>e({panelOpen:!1}),setPendingAction:t=>e({pendingAction:t}),clearPendingAction:()=>e({pendingAction:null}),beginBrowserAuth:({sessionId:t,verificationUri:n,expiresAt:r,intervalMs:i,statusMessage:a})=>e({panelOpen:!0,authSessionId:t,authVerificationUri:n,authExpiresAt:r,authPollIntervalMs:i,authStatusMessage:a}),updateBrowserAuth:({statusMessage:t,intervalMs:n})=>e(e=>({authStatusMessage:t??e.authStatusMessage,authPollIntervalMs:n??e.authPollIntervalMs})),clearBrowserAuth:()=>e({authSessionId:null,authVerificationUri:null,authExpiresAt:null,authStatusMessage:``,authPollIntervalMs:1500}),setAuthStatusMessage:t=>e({authStatusMessage:t})}));function Y({label:e,value:t}){return(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,F.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,F.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function pe(e){let{email:n,username:r,role:i,canSubmitUsername:o,savingUsername:s,usernameDraft:c,onUsernameDraftChange:l,onSubmitUsername:d,onOpenDeviceList:f,onLogout:p}=e;return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(k,{tone:`success`,title:t(`accountPanelSignedInTitle`),description:t(`accountPanelSignedInDescription`)}),(0,F.jsxs)(k,{tone:`neutral`,children:[(0,F.jsx)(Y,{label:t(`remoteAccountEmail`),value:n}),(0,F.jsx)(Y,{label:t(`remoteAccountUsername`),value:r}),(0,F.jsx)(Y,{label:t(`remoteAccountRole`),value:i})]}),r?(0,F.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`remoteAccountUsernameLockedHelp`)}):(0,F.jsxs)(k,{tone:`warning`,title:t(`remoteAccountUsernameRequiredTitle`),description:t(`remoteAccountUsernameRequiredDescription`),children:[(0,F.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,F.jsx)(a,{htmlFor:`account-panel-username`,children:t(`remoteAccountUsername`)}),(0,F.jsx)(x,{id:`account-panel-username`,value:c,onChange:e=>l(e.target.value),placeholder:t(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,F.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,F.jsx)(u,{disabled:!o,onClick:()=>void d(),children:t(s?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,F.jsxs)(u,{onClick:()=>void f(),children:[(0,F.jsx)(M,{className:`mr-2 h-4 w-4`}),t(`remoteOpenDeviceList`)]}),(0,F.jsxs)(u,{variant:`outline`,onClick:()=>void p(),children:[(0,F.jsx)(j,{className:`mr-2 h-4 w-4`}),t(`remoteLogout`)]})]})]})}function me(e){let{authSessionId:n,authExpiresAt:i,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,F.jsxs)(`div`,{className:`space-y-4`,children:[(0,F.jsx)(k,{tone:`neutral`,title:t(`accountPanelSignedOutTitle`),description:t(`accountPanelSignedOutDescription`),children:n?(0,F.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,F.jsx)(Y,{label:t(`remoteBrowserAuthSession`),value:n}),(0,F.jsx)(Y,{label:t(`remoteBrowserAuthExpiresAt`),value:i?r(i):`-`})]}):null}),a?(0,F.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,F.jsx)(u,{onClick:()=>void s(),children:t(n?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,F.jsx)(u,{variant:`outline`,onClick:c,children:t(`remoteBrowserAuthResume`)}):null]})]})}function he(){let e=$(),n=N(),r=J(e=>e.panelOpen),i=J(e=>e.authSessionId),a=J(e=>e.authVerificationUri),o=J(e=>e.authExpiresAt),s=J(e=>e.authStatusMessage),c=n.data,[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(!1);(0,P.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,F.jsx)(E,{open:r,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,F.jsxs)(re,{className:`max-w-xl`,children:[(0,F.jsxs)(ne,{children:[(0,F.jsxs)(ie,{className:`flex items-center gap-2`,children:[(0,F.jsx)(oe,{className:`h-5 w-5 text-primary`}),t(`accountPanelTitle`)]}),(0,F.jsx)(ae,{children:t(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,F.jsx)(pe,{email:c.account.email,username:c.account.username,role:c.account.role,canSubmitUsername:p,savingUsername:d,usernameDraft:l,onUsernameDraftChange:u,onSubmitUsername:async()=>{f(!0);try{await e.accountManager.updateUsername(l)}finally{f(!1)}},onOpenDeviceList:()=>e.accountManager.openNextClawWeb(`/account`),onLogout:()=>e.accountManager.logout()}):(0,F.jsx)(me,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function X({username:e}){let n=y(),[r,i]=(0,P.useState)(e??``),[a,l]=(0,P.useState)(``),d=r.trim().length>0&&a.length>0&&!n.isPending;return(0,F.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,F.jsxs)(o,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,F.jsxs)(c,{children:[(0,F.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:t(`authBrand`)}),(0,F.jsx)(s,{className:`text-2xl`,children:t(`authLoginTitle`)}),(0,F.jsx)(h,{children:t(`authLoginDescription`)})]}),(0,F.jsx)(T,{children:(0,F.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),d&&n.mutate({username:r.trim(),password:a})},children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:t(`authUsername`)}),(0,F.jsx)(x,{value:r,onChange:e=>i(e.target.value),placeholder:t(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:t(`authPassword`)}),(0,F.jsx)(x,{type:`password`,value:a,onChange:e=>l(e.target.value),placeholder:t(`authPasswordPlaceholder`)})]}),(0,F.jsx)(u,{type:`submit`,className:`w-full`,disabled:!d,children:n.isPending?t(`authLoggingIn`):t(`authLoginAction`)})]})})]})})}var ge=class{constructor(){this.authPollTimerId=null,this.afterSignedIn=null,this.bindSignedInContinuation=e=>{this.afterSignedIn=e},this.openAccountPanel=()=>{J.getState().openPanel()},this.closeAccountPanel=()=>{J.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),J.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=await R();return t.account.loggedIn?!0:(e?.pendingAction&&J.getState().setPendingAction(e.pendingAction),this.openAccountPanel(),await this.startBrowserSignIn({apiBase:e?.apiBase,status:t}),!1)},this.startBrowserSignIn=async e=>{try{let n=e?.apiBase,r=e?.pendingAction,i=e?.status??await R();r&&J.getState().setPendingAction(r);let a=await te({apiBase:B(i,n)});J.getState().beginBrowserAuth({sessionId:a.sessionId,verificationUri:a.verificationUri,expiresAt:a.expiresAt,intervalMs:a.intervalMs,statusMessage:t(`remoteBrowserAuthWaiting`)}),window.open(a.verificationUri,`_blank`,`noopener,noreferrer`)||J.getState().setAuthStatusMessage(t(`remoteBrowserAuthPopupBlocked`)),this.scheduleBrowserAuthPoll()}catch(e){let n=e instanceof Error?e.message:t(`remoteBrowserAuthStartFailed`);l.error(`${t(`remoteBrowserAuthStartFailed`)}: ${n}`)}},this.resumeBrowserSignIn=()=>{let e=J.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await C(),J.getState().clearPendingAction(),J.getState().clearBrowserAuth(),await z(),l.success(t(`remoteLogoutSuccess`))}catch(e){let n=e instanceof Error?e.message:t(`remoteLogoutFailed`);l.error(`${t(`remoteLogoutFailed`)}: ${n}`)}},this.updateUsername=async e=>{try{await w({username:e.trim()}),await z(),l.success(t(`remoteAccountUsernameSetSuccess`))}catch(e){let n=e instanceof Error?e.message:t(`remoteAccountUsernameSetFailed`);l.error(`${t(`remoteAccountUsernameSetFailed`)}: ${n}`)}},this.openNextClawWeb=async(e=`/`)=>{let n=H(await R());if(!n){l.error(t(`remoteOpenWebUnavailable`));return}let r=new URL(e,`${n.replace(/\/+$/,``)}/`).toString();window.open(r,`_blank`,`noopener,noreferrer`)},this.scheduleBrowserAuthPoll=()=>{this.clearPollTimer();let{authSessionId:e,authPollIntervalMs:t}=J.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=J.getState();if(e.authSessionId)try{let n=await R(),r=await _({sessionId:e.authSessionId,apiBase:B(n)});if(r.status===`pending`){J.getState().updateBrowserAuth({statusMessage:t(`remoteBrowserAuthWaiting`),intervalMs:r.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(r.status===`expired`){this.clearPollTimer(),J.getState().clearBrowserAuth(),l.error(r.message||t(`remoteBrowserAuthExpired`));return}J.getState().setAuthStatusMessage(t(`remoteBrowserAuthCompleted`));let i=await z(),{pendingAction:a}=J.getState();this.clearPollTimer(),J.getState().clearBrowserAuth(),l.success(t(`remoteLoginSuccess`)),a&&this.afterSignedIn&&await this.afterSignedIn(a,i),J.getState().clearPendingAction()}catch(e){this.clearPollTimer(),J.getState().clearBrowserAuth();let n=e instanceof Error?e.message:t(`remoteBrowserAuthPollFailed`);l.error(`${t(`remoteBrowserAuthPollFailed`)}: ${n}`)}},this.clearPollTimer=()=>{this.authPollTimerId!==null&&(window.clearTimeout(this.authPollTimerId),this.authPollTimerId=null)},this.getBrowserAuthSummary=()=>{let e=J.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?r(e.authExpiresAt):`-`}}}},Z=new class{constructor(){this.accountManager=new ge,this.remoteAccessManager=new W}};Z.accountManager.bindSignedInContinuation(Z.remoteAccessManager.resumePendingActionAfterSignIn),Z.remoteAccessManager.bindAccountManager(Z.accountManager);var Q=(0,P.createContext)(null);function _e({children:e}){return(0,F.jsx)(Q.Provider,{value:Z,children:e})}function $(){let e=(0,P.useContext)(Q);if(!e)throw Error(`useAppManager must be used inside AppManagerProvider`);return e}export{q as a,U as c,z as d,B as f,N as h,he as i,L as l,ce as m,$ as n,K as o,H as p,X as r,W as s,_e as t,R as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,n as r,p as i,u as a}from"./i18n-C5Mibli1.js";import{Ct as o,Mt as s,Ot as c,jt as l,kt as u,vt as d,wt as f}from"./api-C412zuay.js";import{c as p,l as m,s as h}from"./chunk-JZWAC4HX-DvbcIVPf.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./dialog-B-CXiFPZ.js";import{t as S}from"./createLucideIcon-BZkY6emz.js";import{_ as C,m as w,v as T}from"./theme-provider-DeBrTglS.js";import{A as E,B as D,C as ee,D as O,E as te,F as ne,L as re,M as ie,N as k,O as A,P as ae,S as oe,T as se,_ as j,a as ce,b as le,c as ue,d as M,f as de,g as fe,h as N,i as pe,j as P,k as me,l as he,m as ge,n as _e,o as ve,p as ye,r as be,s as F,t as xe,u as Se,v as Ce,w as we,x as Te,y as I,z as L}from"./chat-ChCu7LQD.js";import{a as R,i as z,n as B,r as V,t as H}from"./select-BELPuXLW.js";import{i as Ee,n as U,r as De,t as W}from"./provider-scoped-model-input-CL9sti2I.js";import{t as Oe}from"./refresh-cw-BxojR62w.js";import"./mcp-marketplace-page-DuEixgSs.js";import{t as ke}from"./play-D8WJLnJe.js";import{t as G}from"./plus-Di0KAkiO.js";import{t as K}from"./sparkles-D1ZKWdm4.js";import{t as q}from"./trash-2-rY9ZteZX.js";import{t as J}from"./notice-card-CozHB03G.js";import{t as Ae}from"./use-viewport-layout-CWHVDC6z.js";import{g as je,m as Me,n as Y,o as Ne,p as Pe,r as X,s as Fe,y as Ie}from"./use-config-CrWZ_TSF.js";import{t as Le}from"./index-CqPDhosM.js";import{t as Re}from"./tag-chip-D9BWWgYg.js";import{t as ze}from"./use-confirm-dialog-hbynwWf2.js";import{t as Be}from"./marketplace-page-C9oZ01rM.js";var Ve=S(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),He=S(`ShieldCheck`,[[`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 12 2 2 4-4`,key:`dzmm74`}]]),Z=e(n(),1),Q=i(),$=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`textarea`,{className:a(`flex min-h-28 w-full rounded-xl border border-gray-200/80 bg-white px-3.5 py-2.5 text-sm text-gray-900 placeholder:text-gray-300 placeholder:font-normal focus:outline-none focus:ring-1 focus:ring-primary/40 focus:border-primary/40 transition-colors disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));$.displayName=`Textarea`;var Ue={id:``,displayName:``,description:``,avatar:``,model:``,home:``,runtime:``};function We(e){return{displayName:e.displayName??``,description:e.description??``,avatar:e.avatar??``,model:e.model??``,runtime:e.runtime??e.engine??``}}function Ge(e){let{runtimeOptions:t,currentRuntime:n}=e,r=n.trim();if(!r)return t;let i=N(r);return t.some(e=>e.value===i)?t:[...t,{value:i,label:j(i),icon:null,ready:!1,reason:`unavailable`,reasonMessage:null,supportedModels:void 0,recommendedModel:null,cta:null}].sort((e,t)=>e.value===`native`?-1:t.value===`native`?1:e.value.localeCompare(t.value))}function Ke({value:e,disabled:n=!1,runtimeOptions:r,defaultRuntime:i,onChange:a}){let o=e.trim()?N(e):``,s=Ge({runtimeOptions:r,currentRuntime:e}),c=s.find(e=>e.value===o)??null,l=c?.reasonMessage?.trim()||(c?.ready===!1?t(`agentsRuntimeUnavailableHelp`):``);return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsxs)(H,{value:o||i,onValueChange:e=>a(e===i?``:e),disabled:n,children:[(0,Q.jsx)(z,{"aria-label":t(`agentsCardRuntimeLabel`),className:`rounded-xl`,children:(0,Q.jsx)(R,{placeholder:t(`agentsRuntimeSelectPlaceholder`)})}),(0,Q.jsx)(B,{className:`rounded-xl`,children:s.map(e=>(0,Q.jsx)(V,{value:e.value,disabled:e.ready===!1&&e.value!==o,className:`rounded-lg`,children:e.label},e.value))})]}),l?(0,Q.jsx)(`p`,{className:`text-xs text-gray-500`,children:l}):null]})}function qe({open:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,Q.jsx)(x,{open:e,onOpenChange:a,children:e||t?(0,Q.jsx)(Ye,{pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e?`create-open`:`create-closed`):null})}function Je({agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o}){return(0,Q.jsx)(x,{open:e!==null,onOpenChange:a,children:e?(0,Q.jsx)(Xe,{agent:e,pending:t,providerCatalog:n,runtimeOptions:r,defaultRuntime:i,onOpenChange:a,onSubmit:o},e.id):null})}function Ye(e){let{pending:n,providerCatalog:r,runtimeOptions:i,defaultRuntime:a,onOpenChange:o,onSubmit:c}=e,[u,d]=(0,Z.useState)(Ue);return(0,Q.jsxs)(v,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,Q.jsxs)(g,{className:`text-left`,children:[(0,Q.jsx)(y,{children:t(`agentsCreateDialogTitle`)}),(0,Q.jsx)(b,{children:t(`agentsCreateDialogDescription`)})]})}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Q.jsx)(l,{value:u.id,onChange:e=>d(t=>({...t,id:e.target.value})),placeholder:t(`agentsFormIdPlaceholder`)}),(0,Q.jsx)(l,{value:u.displayName,onChange:e=>d(t=>({...t,displayName:e.target.value})),placeholder:t(`agentsFormNamePlaceholder`)}),(0,Q.jsx)($,{value:u.description,onChange:e=>d(t=>({...t,description:e.target.value})),placeholder:t(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,Q.jsx)(l,{value:u.avatar,onChange:e=>d(t=>({...t,avatar:e.target.value})),placeholder:t(`agentsFormAvatarPlaceholder`)}),(0,Q.jsx)(l,{value:u.home,onChange:e=>d(t=>({...t,home:e.target.value})),placeholder:t(`agentsFormHomePlaceholder`)}),(0,Q.jsx)(W,{value:u.model,onChange:e=>d(t=>({...t,model:e})),providerCatalog:r,disabled:n,className:`md:col-span-2`}),(0,Q.jsx)(Ke,{value:u.runtime,onChange:e=>d(t=>({...t,runtime:e})),runtimeOptions:i,defaultRuntime:a,disabled:n})]}),(0,Q.jsx)(J,{tone:`warning`,title:t(`agentsCreateDialogHint`),className:`text-xs leading-6`})]})}),(0,Q.jsxs)(_,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,Q.jsx)(s,{type:`button`,variant:`ghost`,onClick:()=>o(!1),disabled:n,children:t(`cancel`)}),(0,Q.jsxs)(s,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>void c(u),disabled:n||u.id.trim().length===0,children:[(0,Q.jsx)(G,{className:`mr-2 h-4 w-4`}),t(`agentsCreateAction`)]})]})]})}function Xe(e){let{agent:n,pending:r,providerCatalog:i,runtimeOptions:a,defaultRuntime:o,onOpenChange:c,onSubmit:u}=e,[d,f]=(0,Z.useState)(We(n));return(0,Q.jsxs)(v,{className:`flex max-h-[calc(100vh-2rem)] flex-col overflow-hidden border-none bg-[linear-gradient(180deg,#fff9f1_0%,#ffffff_24%)] p-0 sm:max-h-[760px] sm:max-w-xl`,children:[(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-[#f0e2c8] px-6 py-6`,children:(0,Q.jsxs)(g,{className:`text-left`,children:[(0,Q.jsx)(y,{children:t(`agentsEditDialogTitle`)}),(0,Q.jsx)(b,{children:t(`agentsEditDialogDescription`)})]})}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-6 py-6`,children:(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(J,{tone:`warning`,title:t(`agentsEditHomeReadonly`),description:t(`agentsEditHomeReadonlyHint`),children:(0,Q.jsx)(`div`,{className:`break-all text-sm text-amber-950`,children:n.workspace??`-`})}),(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,Q.jsx)(l,{value:d.displayName,onChange:e=>f(t=>({...t,displayName:e.target.value})),placeholder:t(`agentsFormNamePlaceholder`)}),(0,Q.jsx)($,{value:d.description,onChange:e=>f(t=>({...t,description:e.target.value})),placeholder:t(`agentsFormDescriptionPlaceholder`),rows:4,className:`md:col-span-2`}),(0,Q.jsx)(l,{value:d.avatar,onChange:e=>f(t=>({...t,avatar:e.target.value})),placeholder:t(`agentsFormAvatarPlaceholder`)}),(0,Q.jsx)(W,{value:d.model,onChange:e=>f(t=>({...t,model:e})),providerCatalog:i,disabled:r,className:`md:col-span-2`}),(0,Q.jsx)(Ke,{value:d.runtime,onChange:e=>f(t=>({...t,runtime:e})),runtimeOptions:a,defaultRuntime:o,disabled:r})]})]})}),(0,Q.jsxs)(_,{className:`shrink-0 border-t border-[#f1e7d4] px-6 py-5`,children:[(0,Q.jsx)(s,{type:`button`,variant:`ghost`,onClick:()=>c(!1),disabled:r,children:t(`cancel`)}),(0,Q.jsxs)(s,{type:`button`,variant:`primary`,className:`rounded-2xl px-5`,onClick:()=>u(n.id,d),disabled:r,children:[(0,Q.jsx)(L,{className:`mr-2 h-4 w-4`}),t(`agentsEditSaveAction`)]})]})]})}var Ze=[{strip:`bg-[#efc37a]`,chip:`border-[#f2d7a7] bg-[#fff8eb] text-[#8d5a18]`},{strip:`bg-[#8fd4c0]`,chip:`border-[#bde6da] bg-[#effbf7] text-[#156653]`},{strip:`bg-[#b7c9fb]`,chip:`border-[#d7e2ff] bg-[#f4f7ff] text-[#2d4d8f]`}];function Qe(e,t){return t?{strip:`bg-[#e6b765]`,chip:`border-[#f2d19c] bg-[#fff8ec] text-[#90550d]`}:Ze[e%Ze.length]}function $e(e){let{agentCount:n,onCreate:r}=e;return(0,Q.jsxs)(`section`,{className:`relative overflow-hidden rounded-[28px] border border-[#f0d6aa] bg-[linear-gradient(135deg,#fff7ea_0%,#fff9f1_32%,#f2fbff_100%)] px-5 py-5 sm:px-6`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-y-0 right-0 w-[46%] bg-[radial-gradient(circle_at_top_right,rgba(255,215,163,0.52),transparent_54%)]`}),(0,Q.jsx)(`div`,{className:`absolute -bottom-10 left-8 h-32 w-32 rounded-full bg-[#ffe6c0]/55 blur-3xl`}),(0,Q.jsxs)(`div`,{className:`relative grid gap-5 xl:grid-cols-[minmax(0,1fr)_320px] xl:items-center`,children:[(0,Q.jsxs)(`div`,{className:`max-w-3xl space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full border border-white/70 bg-white/80 px-3 py-1 text-[11px] font-semibold tracking-[0.16em] text-[#9b6118]`,children:[(0,Q.jsx)(K,{className:`h-3.5 w-3.5`}),t(`agentsHeroEyebrow`)]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`h1`,{className:`max-w-2xl text-[30px] font-semibold leading-tight tracking-[-0.05em] text-[#2f2212] sm:text-[38px]`,children:t(`agentsHeroTitle`)}),(0,Q.jsx)(`p`,{className:`max-w-2xl text-sm leading-6 text-[#6d5841] sm:text-[15px] sm:leading-7`,children:t(`agentsHeroDescription`)})]}),(0,Q.jsx)(`div`,{className:`pt-1`,children:(0,Q.jsxs)(`div`,{className:`inline-flex items-center gap-3 rounded-2xl border border-[#f2d5a4] bg-white/82 px-3 py-2 text-[#7a4d12] shadow-[0_14px_30px_rgba(167,117,47,0.07)]`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[0.14em]`,children:t(`agentsOverviewTotal`)}),(0,Q.jsx)(`span`,{className:`text-xl font-semibold tracking-[-0.04em] text-[#1f2937]`,children:n})]})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-3`,children:[(0,Q.jsxs)(s,{type:`button`,variant:`primary`,className:`h-10 rounded-2xl px-5 text-sm font-semibold`,onClick:r,children:[(0,Q.jsx)(G,{className:`mr-2 h-4 w-4`}),t(`agentsCreateButton`)]}),(0,Q.jsx)(J,{title:t(`agentsCreateDialogHint`),className:`border-white/70 bg-white/72 text-xs leading-6 shadow-[0_18px_40px_rgba(167,117,47,0.08)]`})]})]})]})}function et(e){let{agent:n,index:r,runtimeOptions:i,defaultRuntimeLabel:c,updatePending:l,deletePending:u,onStartChat:d,onEdit:p,onDelete:m}=e,h=Qe(r,!!n.builtIn),g=n.runtime?.trim()||n.engine?.trim()||``,_=g?i.find(e=>e.value===N(g))?.label??j(g):c;return(0,Q.jsxs)(o,{className:`overflow-hidden border border-gray-200 bg-white shadow-sm transition-shadow duration-200 hover:shadow-md`,children:[(0,Q.jsx)(`div`,{className:a(`h-1.5 w-full`,h.strip)}),(0,Q.jsxs)(f,{className:`flex h-full flex-col gap-4 px-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(re,{agentId:n.id,displayName:n.displayName,avatarUrl:n.avatarUrl,className:`h-11 w-11 shrink-0`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1 pt-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`truncate text-lg font-semibold tracking-[-0.03em] text-[#1f2937]`,children:n.displayName?.trim()||n.id}),n.builtIn?(0,Q.jsxs)(Re,{tone:`warning`,className:a(`gap-1`,h.chip),children:[(0,Q.jsx)(He,{className:`h-3 w-3`}),t(`agentsCardBuiltInTag`)]}):null]}),(0,Q.jsxs)(`div`,{className:`text-[11px] font-medium uppercase tracking-[0.18em] text-[#94a3b8]`,children:[`@`,n.id]})]})]}),(0,Q.jsx)(`p`,{className:`text-sm leading-6 text-[#64748b]`,children:n.description?.trim()||(n.builtIn?t(`agentsCardBuiltInSummary`):t(`agentsCardCustomSummary`))}),(0,Q.jsxs)(`div`,{className:`mt-auto flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.18em] text-[#94a3b8]`,children:[(0,Q.jsx)(K,{className:`h-3.5 w-3.5`}),t(`agentsCardRuntimeLabel`)]}),(0,Q.jsx)(`div`,{className:`mt-1.5 text-sm leading-6 text-[#475569]`,children:_})]}),(0,Q.jsxs)(`div`,{className:`border-t border-gray-100 pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold uppercase tracking-[0.18em] text-[#94a3b8]`,children:[(0,Q.jsx)(D,{className:`h-3.5 w-3.5`}),t(`agentsCardHomeLabel`)]}),(0,Q.jsx)(`div`,{className:`mt-1.5 break-all text-sm leading-6 text-[#475569]`,children:n.workspace??`-`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(s,{type:`button`,variant:`primary`,className:`h-9 rounded-xl px-4`,onClick:d,children:[(0,Q.jsx)(w,{className:`mr-2 h-4 w-4`}),t(`agentsCardStartChat`)]}),(0,Q.jsxs)(s,{type:`button`,variant:`ghost`,className:`h-8 rounded-xl px-3 text-xs text-[#7b8794] hover:bg-[#f3f4f6] hover:text-[#475569]`,onClick:p,disabled:l,children:[(0,Q.jsx)(L,{className:`mr-1.5 h-3.5 w-3.5`}),t(`agentsEditAction`)]}),n.builtIn?null:(0,Q.jsxs)(s,{type:`button`,variant:`ghost`,className:`h-8 rounded-xl px-3 text-xs text-[#7b8794] hover:bg-[#f3f4f6] hover:text-[#475569]`,onClick:m,disabled:u,children:[(0,Q.jsx)(q,{className:`mr-1.5 h-3.5 w-3.5`}),t(`agentsRemoveAction`)]})]})]})]})]})}function tt(){let e=p(),n=I(),r=Y(),i=X(),a=F(),c=le(),l=oe(),d=Te(),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),v=A(e=>e.setSnapshot),y=(0,Z.useMemo)(()=>n.data?.agents??[],[n.data?.agents]),b=(0,Z.useMemo)(()=>[...y].sort((e,t)=>Number(!!t.builtIn)-Number(!!e.builtIn)||e.id.localeCompare(t.id)),[y]),x=(0,Z.useMemo)(()=>U({config:r.data,meta:i.data,onlyConfigured:!0}),[i.data,r.data]),S=(0,Z.useMemo)(()=>ge(a.data?.options??[]),[a.data?.options]),w=(0,Z.useMemo)(()=>N(a.data?.defaultType??`native`),[a.data?.defaultType]),T=(0,Z.useMemo)(()=>S.find(e=>e.value===w)?.label??j(w),[w,S]),E=async e=>{await c.mutateAsync({data:{id:e.id,...e.displayName.trim()?{displayName:e.displayName.trim()}:{},...e.description.trim()?{description:e.description.trim()}:{},...e.avatar.trim()?{avatar:e.avatar.trim()}:{},...e.home.trim()?{home:e.home.trim()}:{},...e.model.trim()?{model:e.model.trim()}:{},...e.runtime.trim()?{runtime:e.runtime.trim()}:{}}}),h(!1)},D=e=>{_(e)},ee=async(e,t)=>{await l.mutateAsync({agentId:e,data:{displayName:t.displayName,description:t.description,avatar:t.avatar,model:t.model,...t.runtime.trim()?{runtime:t.runtime.trim()}:{runtime:``}}}),_(null)},O=t=>{v({selectedAgentId:t.id,selectedSessionKey:null}),k.getState().setSnapshot({pendingSessionType:fe(t,w),pendingProjectRoot:null,pendingProjectRootSessionKey:null}),e(`/chat`)};return(0,Q.jsxs)(u,{className:`space-y-5`,children:[(0,Q.jsx)($e,{agentCount:y.length,onCreate:()=>h(!0)}),(0,Q.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:n.isLoading?(0,Q.jsx)(o,{className:`md:col-span-2 xl:col-span-3 border-dashed border-[#d9dce3] bg-white/70`,children:(0,Q.jsx)(f,{className:`py-14 text-center text-sm text-gray-500`,children:t(`agentsLoading`)})}):b.length===0?(0,Q.jsx)(o,{className:`md:col-span-2 xl:col-span-3 overflow-hidden border-dashed border-[#d9dce3] bg-[linear-gradient(135deg,#fff7ea_0%,#f4fbff_100%)]`,children:(0,Q.jsxs)(f,{className:`flex min-h-[240px] flex-col items-center justify-center px-6 py-14 text-center`,children:[(0,Q.jsx)(`div`,{className:`mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-white/80 shadow-[0_18px_44px_rgba(0,0,0,0.08)]`,children:(0,Q.jsx)(C,{className:`h-8 w-8 text-[#d39a3b]`})}),(0,Q.jsx)(`div`,{className:`text-lg font-semibold text-[#2f2212]`,children:t(`agentsEmpty`)}),(0,Q.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-[#78644d]`,children:t(`agentsEmptyDescription`)}),(0,Q.jsxs)(s,{type:`button`,variant:`primary`,className:`mt-5 rounded-2xl px-5`,onClick:()=>h(!0),children:[(0,Q.jsx)(G,{className:`mr-2 h-4 w-4`}),t(`agentsCreateButton`)]})]})}):b.map((e,t)=>(0,Q.jsx)(et,{agent:e,index:t,runtimeOptions:S,defaultRuntimeLabel:T,updatePending:l.isPending,deletePending:d.isPending,onStartChat:()=>O(e),onEdit:()=>D(e),onDelete:()=>d.mutate({agentId:e.id})},e.id))}),(0,Q.jsx)(qe,{open:m,pending:c.isPending,providerCatalog:x,runtimeOptions:S,defaultRuntime:w,onOpenChange:h,onSubmit:E}),(0,Q.jsx)(Je,{agent:g,pending:l.isPending,providerCatalog:x,runtimeOptions:S,defaultRuntime:w,onOpenChange:e=>{!e&&!l.isPending&&_(null)},onSubmit:ee})]})}function nt(e){return r(e??void 0)}function rt(e){return typeof e!=`number`||!Number.isFinite(e)?`-`:r(new Date(e))}function it(e){if(typeof e!=`number`||!Number.isFinite(e))return`-`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.round(t/60);if(n<60)return`${n}m`;let r=Math.round(n/60);return r<24?`${r}h`:`${Math.round(r/24)}d`}function at(e){let{schedule:t}=e;return t.kind===`cron`?t.expr?`cron ${t.expr}`:`cron`:t.kind===`every`?`every ${it(t.everyMs)}`:t.kind===`at`?`at ${rt(t.atMs)}`:`-`}function ot(e){return e.payload.deliver?`${e.payload.channel??`-`}:${e.payload.to??`-`}`:`-`}function st(e){return e.payload.sessionId?.trim()||`cron:${e.id}`}function ct(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.name,e.payload.message,e.payload.sessionId??``,e.payload.channel??``,e.payload.to??``].join(` `).toLowerCase().includes(n):!0}function lt(e,t){return t===`all`?!0:t===`enabled`?e.enabled:!e.enabled}function ut(e){let{job:n,onDelete:r,onRun:i,onToggle:c}=e;return(0,Q.jsx)(o,{className:`border border-gray-200`,children:(0,Q.jsx)(f,{className:`pt-5 pb-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-[220px] flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-semibold text-gray-900`,children:n.name||n.id}),(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-semibold text-gray-500`,children:n.id}),(0,Q.jsx)(`span`,{className:a(`rounded-full px-2 py-0.5 text-[10px] font-semibold`,n.enabled?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-500`),children:n.enabled?t(`enabled`):t(`disabled`)}),n.deleteAfterRun?(0,Q.jsx)(`span`,{className:`rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-semibold text-amber-700`,children:t(`cronOneShot`)}):null]}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[t(`cronScheduleLabel`),`: `,at(n)]}),(0,Q.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-gray-700`,children:n.payload.message}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[t(`cronSessionLabel`),`: `,st(n)]}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs text-gray-500`,children:[t(`cronDeliverTo`),`: `,ot(n)]})]}),(0,Q.jsxs)(`div`,{className:`min-w-[220px] space-y-2 text-xs text-gray-500`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[t(`cronNextRun`),`:`]}),` `,nt(n.state.nextRunAt)]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[t(`cronLastRun`),`:`]}),` `,nt(n.state.lastRunAt)]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`span`,{className:`font-medium text-gray-700`,children:[t(`cronLastStatus`),`:`]}),` `,n.state.lastStatus??`-`]}),n.state.lastError?(0,Q.jsx)(`div`,{className:`break-words text-[11px] text-red-500`,children:n.state.lastError}):null]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-end gap-2`,children:[(0,Q.jsxs)(s,{variant:`subtle`,size:`sm`,onClick:()=>i(n),className:`gap-1`,children:[(0,Q.jsx)(ke,{className:`h-3.5 w-3.5`}),t(`cronRunNow`)]}),(0,Q.jsxs)(s,{variant:n.enabled?`outline`:`primary`,size:`sm`,onClick:()=>c(n),className:`gap-1`,children:[(0,Q.jsx)(Ve,{className:`h-3.5 w-3.5`}),n.enabled?t(`cronDisable`):t(`cronEnable`)]}),(0,Q.jsxs)(s,{variant:`destructive`,size:`sm`,onClick:()=>r(n),className:`gap-1`,children:[(0,Q.jsx)(q,{className:`h-3.5 w-3.5`}),t(`delete`)]})]})]})})})}function dt(){let[e,n]=(0,Z.useState)(``),[r,i]=(0,Z.useState)(`all`),o=Ne({all:!0}),d=Fe(),f=Ie(),p=je(),{confirm:m,ConfirmDialog:h}=ze(),g=(0,Z.useMemo)(()=>(o.data?.jobs??[]).filter(t=>ct(t,e)).filter(e=>lt(e,r)),[o.data,e,r]),_=async e=>{await m({title:`${t(`cronDeleteConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:`destructive`,confirmLabel:t(`delete`)})&&d.mutate({id:e.id})},v=async e=>{let n=!e.enabled;await m({title:n?`${t(`cronEnableConfirm`)}?`:`${t(`cronDisableConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,variant:n?`default`:`destructive`,confirmLabel:t(n?`cronEnable`:`cronDisable`)})&&f.mutate({id:e.id,enabled:n})},y=async e=>{let n=!e.enabled;await m({title:n?`${t(`cronRunForceConfirm`)}?`:`${t(`cronRunConfirm`)}?`,description:e.name?`${e.name} (${e.id})`:e.id,confirmLabel:t(`cronRunNow`)})&&p.mutate({id:e.id,force:n})};return(0,Q.jsxs)(u,{fullHeight:!0,children:[(0,Q.jsx)(c,{title:t(`cronPageTitle`),description:t(`cronPageDescription`),actions:(0,Q.jsx)(s,{variant:`ghost`,size:`icon`,className:`h-9 w-9 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100`,onClick:()=>o.refetch(),children:(0,Q.jsx)(Oe,{className:a(`h-4 w-4`,o.isFetching&&`animate-spin`)})})}),(0,Q.jsx)(`div`,{className:`mb-6`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3 items-center`,children:[(0,Q.jsxs)(`div`,{className:`relative flex-1 min-w-[240px]`,children:[(0,Q.jsx)(l,{value:e,onChange:e=>n(e.target.value),placeholder:t(`cronSearchPlaceholder`),className:`pl-9`}),(0,Q.jsx)(T,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`})]}),(0,Q.jsx)(`div`,{className:`min-w-[180px]`,children:(0,Q.jsxs)(H,{value:r,onValueChange:e=>i(e),children:[(0,Q.jsx)(z,{className:`w-full`,children:(0,Q.jsx)(R,{placeholder:t(`cronStatusLabel`)})}),(0,Q.jsxs)(B,{children:[(0,Q.jsx)(V,{value:`all`,children:t(`cronStatusAll`)}),(0,Q.jsx)(V,{value:`enabled`,children:t(`cronStatusEnabled`)}),(0,Q.jsx)(V,{value:`disabled`,children:t(`cronStatusDisabled`)})]})]})}),(0,Q.jsxs)(`div`,{className:`text-xs text-gray-500 ml-auto`,children:[t(`cronTotalLabel`),`: `,o.data?.total??0,` / `,g.length]})]})}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto custom-scrollbar`,children:o.isLoading?(0,Q.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`cronLoading`)}):g.length===0?(0,Q.jsx)(`div`,{className:`text-sm text-gray-400 p-4 text-center`,children:t(`cronEmpty`)}):(0,Q.jsx)(`div`,{className:`space-y-4`,children:g.map(e=>(0,Q.jsx)(ut,{job:e,onDelete:_,onRun:y,onToggle:v},e.id))})}),(0,Q.jsx)(h,{})]})}function ft(e){let{view:t,routeSessionKey:n,selectedSessionKey:r,setSelectedSessionKey:i,selectedSessionKeyRef:a,resetStreamState:o}=e;(0,Z.useEffect)(()=>{if(t===`chat`){if(n){r!==n&&i(n);return}r!==null&&(i(null),o())}},[o,n,r,i,t]),(0,Z.useEffect)(()=>{a.current=r},[r,a])}function pt({view:e,confirmDialog:t}){let{isMobile:n}=Ae();return(0,Q.jsxs)(`div`,{className:`h-full flex`,children:[n?null:(0,Q.jsx)(Se,{}),e===`chat`?n?(0,Q.jsx)(Le,{}):(0,Q.jsx)(ye,{}):(0,Q.jsx)(`section`,{className:`flex-1 min-h-0 overflow-hidden bg-gradient-to-b from-gray-50/60 to-white`,children:e===`cron`?(0,Q.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1120px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,Q.jsx)(dt,{})})}):e===`agents`?(0,Q.jsx)(`div`,{className:`h-full overflow-auto custom-scrollbar`,children:(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-[min(1180px,100%)] px-4 py-4 sm:px-6 sm:py-5`,children:(0,Q.jsx)(tt,{})})}):(0,Q.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`mx-auto flex h-full min-h-0 w-full max-w-[min(1120px,100%)] flex-col px-4 py-4 sm:px-6 sm:py-5`,children:(0,Q.jsx)(Be,{forcedType:`skills`})})})}),t]})}function mt(e,t){return e.filter(e=>de(e,t))}function ht(e){let{config:t,meta:n}=e;return(0,Z.useMemo)(()=>{let e=U({meta:n,config:t,onlyConfigured:!0}),r=new Set,i=[];for(let t of e)for(let e of t.models){let n=De(t.prefix,e);!n||r.has(n)||(r.add(n),i.push({value:n,modelLabel:e,providerLabel:t.displayName,thinkingCapability:Ee(t.modelThinking,e,t.aliases)}))}return i.sort((e,t)=>{let n=e.providerLabel.localeCompare(t.providerLabel);return n===0?e.modelLabel.localeCompare(t.modelLabel):n})},[t,n])}function gt(e){let{sessions:t,sessionKey:n,sessionType:r}=e;return{recentSessionPreferredModel:(0,Z.useMemo)(()=>xe({sessions:t,selectedSessionKey:n,sessionType:r}),[n,r,t]),recentSessionPreferredThinking:(0,Z.useMemo)(()=>_e({sessions:t,selectedSessionKey:n,sessionType:r}),[n,r,t])}}function _t(e){let{currentSelectedModel:t,modelOptions:n}=e,r=(0,Z.useMemo)(()=>n.find(e=>e.value===t),[t,n]);return{supportedThinkingLevels:(0,Z.useMemo)(()=>r?.thinkingCapability?.supported??[],[r?.thinkingCapability?.supported]),defaultThinkingLevel:(0,Z.useMemo)(()=>r?.thinkingCapability?.default??null,[r?.thinkingCapability?.default])}}function vt(e){let{modelOptions:t,supportedModels:n}=e;if(!n||n.length===0)return t;let r=new Set(n),i=t.filter(e=>r.has(e.value));return i.length>0?i:t}function yt(e){let{currentSelectedModel:t,pendingSessionType:n,projectRootOverride:r,query:i,sessionKey:a,setPendingSessionType:o,setSelectedModel:s,setSelectedThinkingLevel:c}=e,l=Y(),u=X(),d=Me({limit:200}),f=F(),p=Pe({sessionId:a,...Object.prototype.hasOwnProperty.call(e,`projectRootOverride`)?{projectRoot:r??null}:{}}),m=(l.isFetched||l.isSuccess)&&(u.isFetched||u.isSuccess),h=ht({config:l.data,meta:u.data}),g=(0,Z.useMemo)(()=>d.data?.sessions??[],[d.data?.sessions]),_=(0,Z.useMemo)(()=>me(g),[g]),v=(0,Z.useMemo)(()=>mt(_,i),[_,i]),y=(0,Z.useMemo)(()=>_.find(e=>e.key===a)??null,[_,a]),b=(0,Z.useMemo)(()=>p.data?.records??[],[p.data?.records]),x=Ce({selectedSession:y,pendingSessionType:n,setPendingSessionType:o,sessionTypesData:f.data}),S=(0,Z.useMemo)(()=>vt({modelOptions:h,supportedModels:x.selectedSessionTypeOption?.supportedModels}),[h,x.selectedSessionTypeOption?.supportedModels]),{recentSessionPreferredModel:C,recentSessionPreferredThinking:w}=gt({sessions:_,sessionKey:a,sessionType:x.selectedSessionType}),{supportedThinkingLevels:T,defaultThinkingLevel:E}=_t({currentSelectedModel:t,modelOptions:S});return be({modelOptions:S,selectedSessionKey:a,selectedSessionExists:!!y,selectedSessionPreferredModel:y?.preferredModel,fallbackPreferredModel:x.selectedSessionTypeOption?.recommendedModel??C,defaultModel:x.selectedSessionTypeOption?.recommendedModel??l.data?.agents.defaults.model,setSelectedModel:s}),pe({supportedThinkingLevels:T,selectedSessionKey:a,selectedSessionExists:!!y,selectedSessionPreferredThinking:y?.preferredThinking??null,fallbackPreferredThinking:w??null,defaultThinkingLevel:E,setSelectedThinkingLevel:c}),{configQuery:l,configMetaQuery:u,sessionsQuery:d,sessionTypesQuery:f,sessionSkillsQuery:p,isProviderStateResolved:m,modelOptions:S,sessionSummaries:g,sessions:v,skillRecords:b,selectedSession:y,...x}}function bt(e){return e.parentSessionKey?e.sessionSummaries.map(E).filter(t=>t.parentSessionId===e.parentSessionKey).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)).map(e=>({sessionKey:e.key,parentSessionKey:e.parentSessionId??null,label:e.label??null,agentId:e.agentId??null})):[]}function xt(e){let{availableAgents:t,parentSessionId:n,selectedAgentId:r,selectedSession:i,selectedSessionType:a,sessionKey:o,sessionSummaries:s,sessionTypeOptions:c}=e,l=i?M(i):void 0,u=i?.agentId??r,d=t.find(e=>e.id===u)??null,f=(0,Z.useMemo)(()=>{if(!n)return null;let e=s.find(e=>e.sessionId===n)??null;return e?E(e):null},[n,s]),p=c.find(e=>e.value===a)??null;return{currentSessionDisplayName:l,currentAgentId:u,currentAgent:d,parentSession:f,currentSessionTypeLabel:p?.label??j(a),currentSessionTypeIcon:p?.icon??null,currentChildSessionTabs:(0,Z.useMemo)(()=>bt({parentSessionKey:o,sessionSummaries:s}),[o,s])}}function St(e){(0,Z.useEffect)(()=>{e.presenter.chatInputManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,defaultSessionType:e.defaultSessionType,canStopGeneration:e.canStopCurrentRun,stopDisabledReason:e.stopDisabledReason,stopSupported:!0,stopReason:void 0,sendError:e.lastSendError,isSending:e.isSending,modelOptions:e.modelOptions,sessionTypeOptions:e.sessionTypeOptions,selectedSessionType:e.selectedSessionType,canEditSessionType:e.canEditSessionType,sessionTypeUnavailable:e.sessionTypeUnavailable,skillRecords:e.skillRecords,isSkillsLoading:e.isSkillsLoading}),e.presenter.chatThreadManager.syncSnapshot({isProviderStateResolved:e.isProviderStateResolved,modelOptions:e.modelOptions,sessionTypeUnavailable:e.sessionTypeUnavailable,sessionTypeUnavailableMessage:e.sessionTypeUnavailableMessage,sessionTypeLabel:e.currentSessionTypeLabel,sessionTypeIcon:e.currentSessionTypeIcon,sessionKey:e.sessionKey,agentId:e.currentAgentId,agentDisplayName:e.currentAgent?.displayName??null,agentAvatarUrl:e.currentAgent?.avatarUrl??null,availableAgents:e.availableAgents,sessionDisplayName:e.currentSessionDisplayName,sessionProjectRoot:e.effectiveSessionProjectRoot,sessionProjectName:e.effectiveSessionProjectName,canDeleteSession:!!e.selectedSession,threadRef:e.threadRef,isHistoryLoading:e.agent.isHydrating,messages:e.agent.visibleMessages,isSending:e.isSending,isAwaitingAssistantOutput:e.isAwaitingAssistantOutput,contextWindow:ee(e.agent.snapshot.contextWindow),parentSessionKey:e.parentSession?.key??null,parentSessionLabel:e.parentSession?M(e.parentSession):null,childSessionTabs:e.childSessionTabs})},[e])}function Ct(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){let e=n.trim();e&&t.add(e)}return[...t]}function wt(e){let t={};e.model?.trim()&&(t.model=e.model.trim(),t.preferred_model=e.model.trim()),e.thinkingLevel?.trim()&&(t.thinking=e.thinkingLevel.trim(),t.preferred_thinking=e.thinkingLevel.trim()),e.sessionType?.trim()&&(t.session_type=e.sessionType.trim(),t.runtime=e.sessionType.trim()),e.agentId?.trim()&&(t.agent_id=e.agentId.trim());let n=ie(e.projectRoot);n&&(t.project_root=n);let r=Ct(e.requestedSkills);r.length>0&&(t.requested_skill_refs=r);let i=e.composerNodes?se(e.composerNodes):[];return i.length>0&&(t[we]=i),t}function Tt(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r,selectedSessionProjectRoot:i}=e;return t!==null&&n!==null&&r===n&&(i??null)===t}function Et(e){let t=A(e=>e.snapshot.query),n=A(e=>e.snapshot.selectedSessionKey),r=A(e=>e.snapshot.draftSessionKey),i=A(e=>e.snapshot.selectedAgentId),a=k(e=>e.snapshot.pendingSessionType),o=k(e=>e.snapshot.pendingProjectRoot),s=k(e=>e.snapshot.pendingProjectRootSessionKey),c=k(e=>e.snapshot.selectedModel),l=d(),u=te(l),f=I(),{confirm:g,ConfirmDialog:_}=ze(),v=h(),y=p(),{sessionId:b}=m(),x=(0,Z.useRef)(null),S=(0,Z.useRef)(n),C=(0,Z.useMemo)(()=>ve(b),[b]),w=C??n??r,T=o!==null&&s===w,E=yt({query:t,sessionKey:w,projectRootOverride:T?o:void 0,currentSelectedModel:c,pendingSessionType:a,setPendingSessionType:e.chatInputManager.setPendingSessionType,setSelectedModel:e.chatInputManager.setSelectedModel,setSelectedThinkingLevel:e.chatInputManager.setSelectedThinkingLevel});return{presenter:e,selectedSessionKey:n,selectedAgentId:i,pendingProjectRoot:o,pendingProjectRootSessionKey:s,systemStatus:l,isRuntimeBlocked:u,agentsQuery:f,confirm:g,ConfirmDialog:_,location:v,navigate:y,threadRef:x,selectedSessionKeyRef:S,routeSessionKey:C,sessionKey:w,hasSessionProjectRootOverride:T,agent:he(w),...E}}function Dt(e){let t=Et(e),{agent:n,agentsQuery:r,hasSessionProjectRootOverride:i,pendingProjectRoot:a,isRuntimeBlocked:o,systemStatus:s,selectedAgentId:c,selectedSession:l,selectedSessionType:u,sessionKey:d,sessionSummaries:f,sessionTypeOptions:p}=t,m=i?a:l?.projectRoot??null,h=i?P(m):l?.projectName??P(m),g=n.hydrateError?.message??n.snapshot.error?.message??null,_=s.phase===`ready`&&ue(g)?null:g,v=(r.data?.agents?.length??0)>0?r.data?.agents??[]:[{id:l?.agentId??c}],y=xt({sessionKey:d,selectedSession:l,selectedAgentId:c,availableAgents:v,parentSessionId:l?.parentSessionId??null,sessionSummaries:f,selectedSessionType:u,sessionTypeOptions:p});return{...t,availableAgents:v,effectiveSessionProjectRoot:m,effectiveSessionProjectName:h,isSending:n.isSending||n.isRunning,isAwaitingAssistantOutput:n.isRunning,canStopCurrentRun:n.isRunning,stopDisabledReason:n.isRunning?null:`__preparing__`,lastSendError:o?null:s.phase===`ready`?_:O({message:_,status:s}),...y}}function Ot(e){let{agent:t,pendingProjectRoot:n,pendingProjectRootSessionKey:r,presenter:i,selectedSession:a,selectedSessionKey:o,selectedSessionKeyRef:s,sessionKey:c}=e;(0,Z.useEffect)(()=>{i.chatStreamActionsManager.bind({sendMessage:async e=>{if(e.sessionKey!==c)return;let o=wt({agentId:e.agentId,model:e.model,thinkingLevel:e.thinkingLevel,sessionType:e.sessionType,projectRoot:e.sessionKey===r?n:a?.projectRoot??null,requestedSkills:e.requestedSkills,composerNodes:e.composerNodes}),s=ne({sessionId:e.sessionKey,text:e.message,attachments:e.attachments,parts:e.parts,metadata:o});if(s)try{await t.send(s)}catch(t){throw e.restoreDraftOnError&&(e.composerNodes&&e.composerNodes.length>0?i.chatInputManager.restoreComposerState?.(e.composerNodes,e.attachments??[]):i.chatInputManager.setDraft(t=>t.trim().length===0?e.message:t)),t}},stopCurrentRun:async()=>{await t.abort()},resumeRun:async e=>{e.sessionKey===c&&await t.streamRun()},resetStreamState:()=>{s.current=null},applyHistoryMessages:()=>{}})},[t,n,r,i,o,a?.projectRoot,s,c])}function kt(e){let{pendingProjectRoot:t,pendingProjectRootSessionKey:n,selectedSession:r,selectedSessionKey:i}=e;(0,Z.useEffect)(()=>{!r||!Tt({pendingProjectRoot:t,pendingProjectRootSessionKey:n,sessionKey:r.key,selectedSessionProjectRoot:r.projectRoot??null})||k.getState().setSnapshot({pendingProjectRoot:null,pendingProjectRootSessionKey:null})},[t,n,r,i])}function At(e){let{confirm:t,location:n,navigate:r,presenter:i}=e;(0,Z.useEffect)(()=>{i.chatUiManager.syncState({pathname:n.pathname}),i.chatUiManager.bindActions({navigate:r,confirm:t})},[t,n.pathname,r,i])}function jt(e){let{presenter:t,selectedAgentId:n,selectedSession:r}=e;(0,Z.useEffect)(()=>{!r?.agentId||n===r.agentId||t.chatSessionListManager.setSelectedAgentId(r.agentId)},[t,n,r?.agentId])}function Mt({view:e}){let[t]=(0,Z.useState)(()=>new ce),n=Dt(t);return Ot(n),kt(n),At(n),jt(n),ft({view:e,routeSessionKey:n.routeSessionKey,selectedSessionKey:n.selectedSessionKey,setSelectedSessionKey:t.chatSessionListManager.setSelectedSessionKey,selectedSessionKeyRef:n.selectedSessionKeyRef,resetStreamState:t.chatStreamActionsManager.resetStreamState}),St({presenter:t,isProviderStateResolved:n.isProviderStateResolved,defaultSessionType:n.defaultSessionType,canStopCurrentRun:n.canStopCurrentRun,stopDisabledReason:n.stopDisabledReason,lastSendError:n.lastSendError,isSending:n.isSending,modelOptions:n.modelOptions,sessionTypeOptions:n.sessionTypeOptions,selectedSessionType:n.selectedSessionType,canEditSessionType:n.canEditSessionType,sessionTypeUnavailable:n.sessionTypeUnavailable,skillRecords:n.skillRecords,isSkillsLoading:n.sessionSkillsQuery.isLoading,sessionTypeUnavailableMessage:n.sessionTypeUnavailableMessage,currentSessionTypeLabel:n.currentSessionTypeLabel,currentSessionTypeIcon:n.currentSessionTypeIcon,sessionKey:n.sessionKey,currentAgentId:n.currentAgentId,currentAgent:n.currentAgent,availableAgents:n.availableAgents,currentSessionDisplayName:n.currentSessionDisplayName,effectiveSessionProjectRoot:n.effectiveSessionProjectRoot,effectiveSessionProjectName:n.effectiveSessionProjectName,selectedSession:n.selectedSession,threadRef:n.threadRef,agent:n.agent,isAwaitingAssistantOutput:n.isAwaitingAssistantOutput,parentSession:n.parentSession,childSessionTabs:n.currentChildSessionTabs}),(0,Q.jsx)(ae,{presenter:t,children:(0,Q.jsx)(pt,{view:e,confirmDialog:(0,Q.jsx)(n.ConfirmDialog,{})})})}function Nt({view:e}){return(0,Q.jsx)(Mt,{view:e})}export{Nt as ChatPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{_ as e,m as t}from"./i18n-C5Mibli1.js";import{Kt as n}from"./api-C412zuay.js";var r=e(t(),1),i=`popstate`;function a(e={}){function t(e,t){let{pathname:n,search:r,hash:i}=e.location;return u(``,{pathname:n,search:r,hash:i},t.state&&t.state.usr||null,t.state&&t.state.key||`default`)}function n(e,t){return typeof t==`string`?t:d(t)}return p(t,n,null,e)}function o(e,t){if(e===!1||e==null)throw Error(t)}function s(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function c(){return Math.random().toString(36).substring(2,10)}function l(e,t){return{usr:e.state,key:e.key,idx:t}}function u(e,t,n=null,r){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?f(t):t,state:n,key:t&&t.key||r||c()}}function d({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function f(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function p(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:o=!1}=r,s=a.history,c=`POP`,d=null,f=p();f??(f=0,s.replaceState({...s.state,idx:f},``));function p(){return(s.state||{idx:null}).idx}function h(){c=`POP`;let e=p(),t=e==null?null:e-f;f=e,d&&d({action:c,location:y.location,delta:t})}function g(e,t){c=`PUSH`;let r=u(y.location,e,t);n&&n(r,e),f=p()+1;let i=l(r,f),m=y.createHref(r);try{s.pushState(i,``,m)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;a.location.assign(m)}o&&d&&d({action:c,location:y.location,delta:1})}function _(e,t){c=`REPLACE`;let r=u(y.location,e,t);n&&n(r,e),f=p();let i=l(r,f),a=y.createHref(r);s.replaceState(i,``,a),o&&d&&d({action:c,location:y.location,delta:0})}function v(e){return m(e)}let y={get action(){return c},get location(){return e(a,s)},listen(e){if(d)throw Error(`A history only accepts one active listener`);return a.addEventListener(i,h),d=e,()=>{a.removeEventListener(i,h),d=null}},createHref(e){return t(a,e)},createURL:v,encodeLocation(e){let t=v(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:g,replace:_,go(e){return s.go(e)}};return y}function m(e,t=!1){let n=`http://localhost`;typeof window<`u`&&(n=window.location.origin===`null`?window.location.href:window.location.origin),o(n,`No window.location.(origin|href) available to create URL`);let r=typeof e==`string`?e:d(e);return r=r.replace(/ $/,`%20`),!t&&r.startsWith(`//`)&&(r=n+r),new URL(r,n)}function h(e,t,n=`/`){return g(e,t,n,!1)}function g(e,t,n,r){let i=D((typeof t==`string`?f(t):t).pathname||`/`,n);if(i==null)return null;let a=v(e);b(a);let o=null;for(let e=0;o==null&&e<a.length;++e){let t=oe(i);o=ie(a[e],t,r)}return o}function _(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],loaderData:t[n.id],handle:n.handle}}function v(e,t=[],n=[],r=``,i=!1){let a=(e,a,s=i,c)=>{let l={relativePath:c===void 0?e.path||``:c,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(l.relativePath.startsWith(`/`)){if(!l.relativePath.startsWith(r)&&s)return;o(l.relativePath.startsWith(r),`Absolute route path "${l.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),l.relativePath=l.relativePath.slice(r.length)}let u=j([r,l.relativePath]),d=n.concat(l);e.children&&e.children.length>0&&(o(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${u}".`),v(e.children,t,d,u,s)),!(e.path==null&&!e.index)&&t.push({path:u,score:ne(u,e.index),routesMeta:d})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of y(e.path))a(e,t,!0,n)}),t}function y(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=y(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function b(e){e.sort((e,t)=>e.score===t.score?re(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var x=/^:[\w-]+$/,S=3,C=2,w=1,T=10,ee=-2,te=e=>e===`*`;function ne(e,t){let n=e.split(`/`),r=n.length;return n.some(te)&&(r+=ee),t&&(r+=C),n.filter(e=>!te(e)).reduce((e,t)=>e+(x.test(t)?S:t===``?w:T),r)}function re(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function ie(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u=E({path:s.relativePath,caseSensitive:s.caseSensitive,end:c},l),d=s.route;if(!u&&c&&n&&!r[r.length-1].route.index&&(u=E({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!u)return null;Object.assign(i,u.params),o.push({params:i,pathname:j([a,u.pathname]),pathnameBase:de(j([a,u.pathnameBase])),route:d}),u.pathnameBase!==`/`&&(a=j([a,u.pathnameBase]))}return o}function E(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=ae(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,`$1`),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return n&&!i?e[t]=void 0:e[t]=(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function ae(e,t=!1,n=!0){s(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`)).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function oe(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return s(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function D(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var se=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function ce(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?f(e):e,a;return n?(n=n.replace(/\/\/+/g,`/`),a=n.startsWith(`/`)?le(n.substring(1),`/`):le(n,t)):a=t,{pathname:a,search:fe(r),hash:pe(i)}}function le(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function O(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function ue(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function k(e){let t=ue(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function A(e,t,n,r=!1){let i;typeof e==`string`?i=f(e):(i={...e},o(!i.pathname||!i.pathname.includes(`?`),O(`?`,`pathname`,`search`,i)),o(!i.pathname||!i.pathname.includes(`#`),O(`#`,`pathname`,`hash`,i)),o(!i.search||!i.search.includes(`#`),O(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,s=a?`/`:i.pathname,c;if(s==null)c=n;else{let e=t.length-1;if(!r&&s.startsWith(`..`)){let t=s.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}c=e>=0?t[e]:`/`}let l=ce(i,c),u=s&&s!==`/`&&s.endsWith(`/`),d=(a||s===`.`)&&n.endsWith(`/`);return!l.pathname.endsWith(`/`)&&(u||d)&&(l.pathname+=`/`),l}var j=e=>e.join(`/`).replace(/\/\/+/g,`/`),de=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),fe=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,pe=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,me=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function he(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function ge(e){return e.map(e=>e.route.path).filter(Boolean).join(`/`).replace(/\/\/*/g,`/`)||`/`}var _e=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function ve(e,t){let n=e;if(typeof n!=`string`||!se.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(_e)try{let e=new URL(window.location.href),r=n.startsWith(`//`)?new URL(e.protocol+n):new URL(n),a=D(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{s(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var ye=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(ye);var be=[`GET`,...ye];new Set(be);var M=r.createContext(null);M.displayName=`DataRouter`;var N=r.createContext(null);N.displayName=`DataRouterState`;var xe=r.createContext(!1),Se=r.createContext({isTransitioning:!1});Se.displayName=`ViewTransition`;var Ce=r.createContext(new Map);Ce.displayName=`Fetchers`;var we=r.createContext(null);we.displayName=`Await`;var P=r.createContext(null);P.displayName=`Navigation`;var F=r.createContext(null);F.displayName=`Location`;var I=r.createContext({outlet:null,matches:[],isDataRoute:!1});I.displayName=`Route`;var L=r.createContext(null);L.displayName=`RouteError`;var Te=`REACT_ROUTER_ERROR`,Ee=`REDIRECT`,De=`ROUTE_ERROR_RESPONSE`;function Oe(e){if(e.startsWith(`${Te}:${Ee}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function ke(e){if(e.startsWith(`${Te}:${De}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new me(t.status,t.statusText,t.data)}catch{}}function Ae(e,{relative:t}={}){o(R(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:i}=r.useContext(P),{hash:a,pathname:s,search:c}=V(e,{relative:t}),l=s;return n!==`/`&&(l=s===`/`?n:j([n,s])),i.createHref({pathname:l,search:c,hash:a})}function R(){return r.useContext(F)!=null}function z(){return o(R(),`useLocation() may be used only in the context of a <Router> component.`),r.useContext(F).location}var je=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Me(e){r.useContext(P).static||r.useLayoutEffect(e)}function B(){let{isDataRoute:e}=r.useContext(I);return e?Qe():Ne()}function Ne(){o(R(),`useNavigate() may be used only in the context of a <Router> component.`);let e=r.useContext(M),{basename:t,navigator:n}=r.useContext(P),{matches:i}=r.useContext(I),{pathname:a}=z(),c=JSON.stringify(k(i)),l=r.useRef(!1);return Me(()=>{l.current=!0}),r.useCallback((r,i={})=>{if(s(l.current,je),!l.current)return;if(typeof r==`number`){n.go(r);return}let o=A(r,JSON.parse(c),a,i.relative===`path`);e==null&&t!==`/`&&(o.pathname=o.pathname===`/`?t:j([t,o.pathname])),(i.replace?n.replace:n.push)(o,i.state,i)},[t,n,c,a,e])}r.createContext(null);function Pe(){let{matches:e}=r.useContext(I),t=e[e.length-1];return t?t.params:{}}function V(e,{relative:t}={}){let{matches:n}=r.useContext(I),{pathname:i}=z(),a=JSON.stringify(k(n));return r.useMemo(()=>A(e,JSON.parse(a),i,t===`path`),[e,a,i,t])}function Fe(e,t){return Ie(e,t)}function Ie(e,t,n,i,a){o(R(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:c}=r.useContext(P),{matches:l}=r.useContext(I),u=l[l.length-1],d=u?u.params:{},p=u?u.pathname:`/`,m=u?u.pathnameBase:`/`,g=u&&u.route;{let e=g&&g.path||``;et(p,!g||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
2
|
-
|
|
3
|
-
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let _=z(),v;if(t){let e=typeof t==`string`?f(t):t;o(m===`/`||e.pathname?.startsWith(m),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${e.pathname}" was given in the \`location\` prop.`),v=e}else v=_;let y=v.pathname||`/`,b=y;if(m!==`/`){let e=m.replace(/^\//,``).split(`/`);b=`/`+y.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let x=h(e,{pathname:b});s(g||x!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),s(x==null||x[x.length-1].route.element!==void 0||x[x.length-1].route.Component!==void 0||x[x.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let S=He(x&&x.map(e=>Object.assign({},e,{params:Object.assign({},d,e.params),pathname:j([m,c.encodeLocation?c.encodeLocation(e.pathname.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?m:j([m,c.encodeLocation?c.encodeLocation(e.pathnameBase.replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),l,n,i,a);return t&&S?r.createElement(F.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,...v},navigationType:`POP`}},S):S}function Le(){let e=Ze(),t=he(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i=`rgba(200,200,200, 0.5)`,a={padding:`0.5rem`,backgroundColor:i},o={padding:`2px 4px`,backgroundColor:i},s=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),s=r.createElement(r.Fragment,null,r.createElement(`p`,null,`💿 Hey developer 👋`),r.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,r.createElement(`code`,{style:o},`ErrorBoundary`),` or`,` `,r.createElement(`code`,{style:o},`errorElement`),` prop on your route.`)),r.createElement(r.Fragment,null,r.createElement(`h2`,null,`Unexpected Application Error!`),r.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?r.createElement(`pre`,{style:a},n):null,s)}var Re=r.createElement(Le,null),ze=class extends r.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=ke(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:r.createElement(I.Provider,{value:this.props.routeContext},r.createElement(L.Provider,{value:e,children:this.props.component}));return this.context?r.createElement(Be,{error:e},t):t}};ze.contextType=xe;var H=new WeakMap;function Be({children:e,error:t}){let{basename:n}=r.useContext(P);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=Oe(t.digest);if(e){let i=H.get(t);if(i)throw i;let a=ve(e.location,n);if(_e&&!H.get(t))if(a.isExternal||e.reloadDocument)window.location.href=a.absoluteURL||a.to;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:e.replace}));throw H.set(t,n),n}return r.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${a.absoluteURL||a.to}`})}}return e}function Ve({routeContext:e,match:t,children:n}){let i=r.useContext(M);return i&&i.static&&i.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=t.route.id),r.createElement(I.Provider,{value:e},n)}function He(e,t=[],n=null,i=null,a=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let s=e,c=n?.errors;if(c!=null){let e=s.findIndex(e=>e.route.id&&c?.[e.route.id]!==void 0);o(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(c).join(`,`)}`),s=s.slice(0,Math.min(s.length,e+1))}let l=!1,u=-1;if(n)for(let e=0;e<s.length;e++){let t=s[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(u=e),t.route.id){let{loaderData:e,errors:r}=n,i=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!r||r[t.route.id]===void 0);if(t.route.lazy||i){l=!0,s=u>=0?s.slice(0,u+1):[s[0]];break}}}let d=n&&i?(e,t)=>{i(e,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:ge(n.matches),errorInfo:t})}:void 0;return s.reduceRight((e,i,a)=>{let o,f=!1,p=null,m=null;n&&(o=c&&i.route.id?c[i.route.id]:void 0,p=i.route.errorElement||Re,l&&(u<0&&a===0?(et(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),f=!0,m=null):u===a&&(f=!0,m=i.route.hydrateFallbackElement||null)));let h=t.concat(s.slice(0,a+1)),g=()=>{let t;return t=o?p:f?m:i.route.Component?r.createElement(i.route.Component,null):i.route.element?i.route.element:e,r.createElement(Ve,{match:i,routeContext:{outlet:e,matches:h,isDataRoute:n!=null},children:t})};return n&&(i.route.ErrorBoundary||i.route.errorElement||a===0)?r.createElement(ze,{location:n.location,revalidation:n.revalidation,component:p,error:o,children:g(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:d}):g()},null)}function Ue(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function We(e){let t=r.useContext(M);return o(t,Ue(e)),t}function Ge(e){let t=r.useContext(N);return o(t,Ue(e)),t}function Ke(e){let t=r.useContext(I);return o(t,Ue(e)),t}function qe(e){let t=Ke(e),n=t.matches[t.matches.length-1];return o(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Je(){return qe(`useRouteId`)}function Ye(){return Ge(`useNavigation`).navigation}function Xe(){let{matches:e,loaderData:t}=Ge(`useMatches`);return r.useMemo(()=>e.map(e=>_(e,t)),[e,t])}function Ze(){let e=r.useContext(L),t=Ge(`useRouteError`),n=qe(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Qe(){let{router:e}=We(`useNavigate`),t=qe(`useNavigate`),n=r.useRef(!1);return Me(()=>{n.current=!0}),r.useCallback(async(r,i={})=>{s(n.current,je),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var $e={};function et(e,t,n){!t&&!$e[e]&&($e[e]=!0,s(!1,n))}r.useOptimistic,r.memo(tt);function tt({routes:e,future:t,state:n,onError:r}){return Ie(e,void 0,n,r,t)}function nt({to:e,replace:t,state:n,relative:i}){o(R(),`<Navigate> may be used only in the context of a <Router> component.`);let{static:a}=r.useContext(P);s(!a,`<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.`);let{matches:c}=r.useContext(I),{pathname:l}=z(),u=B(),d=A(e,k(c),l,i===`path`),f=JSON.stringify(d);return r.useEffect(()=>{u(JSON.parse(f),{replace:t,state:n,relative:i})},[u,f,i,t,n]),null}function rt(e){o(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function it({basename:e=`/`,children:t=null,location:n,navigationType:i=`POP`,navigator:a,static:c=!1,unstable_useTransitions:l}){o(!R(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let u=e.replace(/^\/*/,`/`),d=r.useMemo(()=>({basename:u,navigator:a,static:c,unstable_useTransitions:l,future:{}}),[u,a,c,l]);typeof n==`string`&&(n=f(n));let{pathname:p=`/`,search:m=``,hash:h=``,state:g=null,key:_=`default`}=n,v=r.useMemo(()=>{let e=D(p,u);return e==null?null:{location:{pathname:e,search:m,hash:h,state:g,key:_},navigationType:i}},[u,p,m,h,g,_,i]);return s(v!=null,`<Router basename="${u}"> is not able to match the URL "${p}${m}${h}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:r.createElement(P.Provider,{value:d},r.createElement(F.Provider,{children:t,value:v}))}function at({children:e,location:t}){return Fe(U(e),t)}r.Component;function U(e,t=[]){let n=[];return r.Children.forEach(e,(e,i)=>{if(!r.isValidElement(e))return;let a=[...t,i];if(e.type===r.Fragment){n.push.apply(n,U(e.props.children,a));return}o(e.type===rt,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),o(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let s={id:e.props.id||a.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(s.children=U(e.props.children,a)),n.push(s)}),n}var W=`get`,G=`application/x-www-form-urlencoded`;function K(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function ot(e){return K(e)&&e.tagName.toLowerCase()===`button`}function st(e){return K(e)&&e.tagName.toLowerCase()===`form`}function ct(e){return K(e)&&e.tagName.toLowerCase()===`input`}function lt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ut(e,t){return e.button===0&&(!t||t===`_self`)&&!lt(e)}var q=null;function dt(){if(q===null)try{new FormData(document.createElement(`form`),0),q=!1}catch{q=!0}return q}var ft=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function J(e){return e!=null&&!ft.has(e)?(s(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${G}"`),null):e}function pt(e,t){let n,r,i,a,o;if(st(e)){let o=e.getAttribute(`action`);r=o?D(o,t):null,n=e.getAttribute(`method`)||W,i=J(e.getAttribute(`enctype`))||G,a=new FormData(e)}else if(ot(e)||ct(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?D(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||W,i=J(e.getAttribute(`formenctype`))||J(o.getAttribute(`enctype`))||G,a=new FormData(o,e),!dt()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(K(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=W,r=null,i=G,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var mt={"&":`\\u0026`,">":`\\u003e`,"<":`\\u003c`,"\u2028":`\\u2028`,"\u2029":`\\u2029`},ht=/[&><\u2028\u2029]/g;function gt(e){return e.replace(ht,e=>mt[e])}function Y(e,t){if(e===!1||e==null)throw Error(t)}function _t(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return n?i.pathname.endsWith(`/`)?i.pathname=`${i.pathname}_.${r}`:i.pathname=`${i.pathname}.${r}`:i.pathname===`/`?i.pathname=`_root.${r}`:t&&D(i.pathname,t)===`/`?i.pathname=`${t.replace(/\/$/,``)}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,``)}.${r}`,i}async function vt(e,t){if(e.id in t)return t[e.id];try{let r=await n(()=>import(e.module),[]);return t[e.id]=r,r}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function yt(e){return e!=null&&typeof e.page==`string`}function bt(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function xt(e,t,n){return Et((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await vt(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(bt).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function St(e,t,n,r,i,a){let o=(e,t)=>n[t]?e.route.id!==n[t].route.id:!0,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function Ct(e,t,{includeHydrateFallback:n}={}){return wt(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function wt(e){return[...new Set(e)]}function Tt(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function Et(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!yt(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Tt(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Dt(){let e=r.useContext(M);return Y(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function Ot(){let e=r.useContext(N);return Y(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var X=r.createContext(void 0);X.displayName=`FrameworkContext`;function kt(){let e=r.useContext(X);return Y(e,`You must render this element inside a <HydratedRouter> element`),e}function At(e,t){let n=r.useContext(X),[i,a]=r.useState(!1),[o,s]=r.useState(!1),{onFocus:c,onBlur:l,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=t,p=r.useRef(null);r.useEffect(()=>{if(e===`render`&&s(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{s(e.isIntersecting)})},{threshold:.5});return p.current&&e.observe(p.current),()=>{e.disconnect()}}},[e]),r.useEffect(()=>{if(i){let e=setTimeout(()=>{s(!0)},100);return()=>{clearTimeout(e)}}},[i]);let m=()=>{a(!0)},h=()=>{a(!1),s(!1)};return n?e===`intent`?[o,p,{onFocus:Z(c,m),onBlur:Z(l,h),onMouseEnter:Z(u,m),onMouseLeave:Z(d,h),onTouchStart:Z(f,m)}]:[o,p,{}]:[!1,p,{}]}function Z(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function jt({page:e,...t}){let{router:n}=Dt(),i=r.useMemo(()=>h(n.routes,e,n.basename),[n.routes,e,n.basename]);return i?r.createElement(Nt,{page:e,matches:i,...t}):null}function Mt(e){let{manifest:t,routeModules:n}=kt(),[i,a]=r.useState([]);return r.useEffect(()=>{let r=!1;return xt(e,t,n).then(e=>{r||a(e)}),()=>{r=!0}},[e,t,n]),i}function Nt({page:e,matches:t,...n}){let i=z(),{future:a,manifest:o,routeModules:s}=kt(),{basename:c}=Dt(),{loaderData:l,matches:u}=Ot(),d=r.useMemo(()=>St(e,t,u,o,i,`data`),[e,t,u,o,i]),f=r.useMemo(()=>St(e,t,u,o,i,`assets`),[e,t,u,o,i]),p=r.useMemo(()=>{if(e===i.pathname+i.search+i.hash)return[];let n=new Set,r=!1;if(t.forEach(e=>{let t=o.routes[e.route.id];!t||!t.hasLoader||(!d.some(t=>t.route.id===e.route.id)&&e.route.id in l&&s[e.route.id]?.shouldRevalidate||t.hasClientLoader?r=!0:n.add(e.route.id))}),n.size===0)return[];let u=_t(e,c,a.unstable_trailingSlashAwareDataRequests,`data`);return r&&n.size>0&&u.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[u.pathname+u.search]},[c,a.unstable_trailingSlashAwareDataRequests,l,i,o,d,t,e,s]),m=r.useMemo(()=>Ct(f,o),[f,o]),h=Mt(f);return r.createElement(r.Fragment,null,p.map(e=>r.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),m.map(e=>r.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),h.map(({key:e,link:t})=>r.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Pt(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}r.Component;var Ft=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{Ft&&(window.__reactRouterVersion=`7.13.0`)}catch{}function It({basename:e,children:t,unstable_useTransitions:n,window:i}){let o=r.useRef();o.current??=a({window:i,v5Compat:!0});let s=o.current,[c,l]=r.useState({action:s.action,location:s.location}),u=r.useCallback(e=>{n===!1?l(e):r.startTransition(()=>l(e))},[n]);return r.useLayoutEffect(()=>s.listen(u),[s,u]),r.createElement(it,{basename:e,children:t,location:c.location,navigationType:c.action,navigator:s,unstable_useTransitions:n})}function Lt({basename:e,children:t,history:n,unstable_useTransitions:i}){let[a,o]=r.useState({action:n.action,location:n.location}),s=r.useCallback(e=>{i===!1?o(e):r.startTransition(()=>o(e))},[i]);return r.useLayoutEffect(()=>n.listen(s),[n,s]),r.createElement(it,{basename:e,children:t,location:a.location,navigationType:a.action,navigator:n,unstable_useTransitions:i})}Lt.displayName=`unstable_HistoryRouter`;var Rt=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Q=r.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:i,reloadDocument:a,replace:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,unstable_defaultShouldRevalidate:f,...p},m){let{basename:h,unstable_useTransitions:g}=r.useContext(P),_=typeof l==`string`&&Rt.test(l),v=ve(l,h);l=v.to;let y=Ae(l,{relative:i}),[b,x,S]=At(n,p),C=Gt(l,{replace:o,state:s,target:c,preventScrollReset:u,relative:i,viewTransition:d,unstable_defaultShouldRevalidate:f,unstable_useTransitions:g});function w(t){e&&e(t),t.defaultPrevented||C(t)}let T=r.createElement(`a`,{...p,...S,href:v.absoluteURL||y,onClick:v.isExternal||a?e:w,ref:Pt(m,x),target:c,"data-discover":!_&&t===`render`?`true`:void 0});return b&&!_?r.createElement(r.Fragment,null,T,r.createElement(jt,{page:y})):T});Q.displayName=`Link`;var zt=r.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:i=!1,style:a,to:o,viewTransition:s,children:c,...l},u){let d=V(o,{relative:l.relative}),f=z(),p=r.useContext(N),{navigator:m,basename:h}=r.useContext(P),g=p!=null&&en(d)&&s===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;t||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=D(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!i&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!i&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?e:void 0,T;T=typeof n==`function`?n(C):[n,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let ee=typeof a==`function`?a(C):a;return r.createElement(Q,{...l,"aria-current":w,className:T,ref:u,style:ee,to:o,viewTransition:s},typeof c==`function`?c(C):c)});zt.displayName=`NavLink`;var Bt=r.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:i,replace:a,state:o,method:s=W,action:c,onSubmit:l,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},h)=>{let{unstable_useTransitions:g}=r.useContext(P),_=Jt(),v=Yt(c,{relative:u}),y=s.toLowerCase()===`get`?`get`:`post`,b=typeof c==`string`&&Rt.test(c);return r.createElement(`form`,{ref:h,method:y,action:v,onSubmit:i?l:e=>{if(l&&l(e),e.defaultPrevented)return;e.preventDefault();let i=e.nativeEvent.submitter,c=i?.getAttribute(`formmethod`)||s,m=()=>_(i||e.currentTarget,{fetcherKey:t,method:c,navigate:n,replace:a,state:o,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p});g&&n!==!1?r.startTransition(()=>m()):m()},...m,"data-discover":!b&&e===`render`?`true`:void 0})});Bt.displayName=`Form`;function Vt({getKey:e,storageKey:t,...n}){let i=r.useContext(X),{basename:a}=r.useContext(P),o=z(),s=Xe();Qt({getKey:e,storageKey:t});let c=r.useMemo(()=>{if(!i||!e)return null;let t=Zt(o,s,a,e);return t===o.key?null:t},[]);if(!i||i.isSpaMode)return null;let l=((e,t)=>{if(!window.history.state||!window.history.state.key){let e=Math.random().toString(32).slice(2);window.history.replaceState({key:e},``)}try{let n=JSON.parse(sessionStorage.getItem(e)||`{}`)[t||window.history.state.key];typeof n==`number`&&window.scrollTo(0,n)}catch(t){console.error(t),sessionStorage.removeItem(e)}}).toString();return r.createElement(`script`,{...n,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:`(${l})(${gt(JSON.stringify(t||Xt))}, ${gt(JSON.stringify(c))})`}})}Vt.displayName=`ScrollRestoration`;function Ht(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ut(e){let t=r.useContext(M);return o(t,Ht(e)),t}function Wt(e){let t=r.useContext(N);return o(t,Ht(e)),t}function Gt(e,{target:t,replace:n,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c,unstable_useTransitions:l}={}){let u=B(),f=z(),p=V(e,{relative:o});return r.useCallback(m=>{if(ut(m,t)){m.preventDefault();let t=n===void 0?d(f)===d(p):n,h=()=>u(e,{replace:t,state:i,preventScrollReset:a,relative:o,viewTransition:s,unstable_defaultShouldRevalidate:c});l?r.startTransition(()=>h()):h()}},[f,u,p,n,i,t,e,a,o,s,c,l])}var Kt=0,qt=()=>`__${String(++Kt)}__`;function Jt(){let{router:e}=Ut(`useSubmit`),{basename:t}=r.useContext(P),n=Je(),i=e.fetch,a=e.navigate;return r.useCallback(async(e,r={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=pt(e,t);r.navigate===!1?await i(r.fetcherKey||qt(),n,r.action||o,{unstable_defaultShouldRevalidate:r.unstable_defaultShouldRevalidate,preventScrollReset:r.preventScrollReset,formData:l,body:u,formMethod:r.method||s,formEncType:r.encType||c,flushSync:r.flushSync}):await a(r.action||o,{unstable_defaultShouldRevalidate:r.unstable_defaultShouldRevalidate,preventScrollReset:r.preventScrollReset,formData:l,body:u,formMethod:r.method||s,formEncType:r.encType||c,replace:r.replace,state:r.state,fromRouteId:n,flushSync:r.flushSync,viewTransition:r.viewTransition})},[i,a,t,n])}function Yt(e,{relative:t}={}){let{basename:n}=r.useContext(P),i=r.useContext(I);o(i,`useFormAction must be used inside a RouteContext`);let[a]=i.matches.slice(-1),s={...V(e||`.`,{relative:t})},c=z();if(e==null){s.search=c.search;let e=new URLSearchParams(s.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();s.search=n?`?${n}`:``}}return(!e||e===`.`)&&a.route.index&&(s.search=s.search?s.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(s.pathname=s.pathname===`/`?n:j([n,s.pathname])),d(s)}var Xt=`react-router-scroll-positions`,$={};function Zt(e,t,n,r){let i=null;return r&&(i=r(n===`/`?e:{...e,pathname:D(e.pathname,n)||e.pathname},t)),i??=e.key,i}function Qt({getKey:e,storageKey:t}={}){let{router:n}=Ut(`useScrollRestoration`),{restoreScrollPosition:i,preventScrollReset:a}=Wt(`useScrollRestoration`),{basename:o}=r.useContext(P),c=z(),l=Xe(),u=Ye();r.useEffect(()=>(window.history.scrollRestoration=`manual`,()=>{window.history.scrollRestoration=`auto`}),[]),$t(r.useCallback(()=>{if(u.state===`idle`){let t=Zt(c,l,o,e);$[t]=window.scrollY}try{sessionStorage.setItem(t||Xt,JSON.stringify($))}catch(e){s(!1,`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${e}).`)}window.history.scrollRestoration=`auto`},[u.state,e,o,c,l,t])),typeof document<`u`&&(r.useLayoutEffect(()=>{try{let e=sessionStorage.getItem(t||Xt);e&&($=JSON.parse(e))}catch{}},[t]),r.useLayoutEffect(()=>{let t=n?.enableScrollRestoration($,()=>window.scrollY,e?(t,n)=>Zt(t,n,o,e):void 0);return()=>t&&t()},[n,o,e]),r.useLayoutEffect(()=>{if(i!==!1){if(typeof i==`number`){window.scrollTo(0,i);return}try{if(c.hash){let e=document.getElementById(decodeURIComponent(c.hash.slice(1)));if(e){e.scrollIntoView();return}}}catch{s(!1,`"${c.hash.slice(1)}" is not a decodable element ID. The view will not scroll to it.`)}a!==!0&&window.scrollTo(0,0)}},[c,i,a]))}function $t(e,t){let{capture:n}=t||{};r.useEffect(()=>{let t=n==null?void 0:{capture:n};return window.addEventListener(`pagehide`,e,t),()=>{window.removeEventListener(`pagehide`,e,t)}},[e,n])}function en(e,{relative:t}={}){let n=r.useContext(Se);o(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Ut(`useViewTransitionState`),a=V(e,{relative:t});if(!n.isTransitioning)return!1;let s=D(n.currentLocation.pathname,i)||n.currentLocation.pathname,c=D(n.nextLocation.pathname,i)||n.nextLocation.pathname;return E(a.pathname,c)!=null||E(a.pathname,s)!=null}export{rt as a,B as c,nt as i,Pe as l,Q as n,at as o,zt as r,z as s,It as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/doc-browser-Doh2541x.js","assets/doc-browser-CzCV73NJ.js","assets/i18n-C5Mibli1.js","assets/createLucideIcon-BZkY6emz.js","assets/search-vChioOoe.js","assets/book-open-DgLqYpNY.js","assets/external-link-Sw3ah_JD.js","assets/plus-Di0KAkiO.js","assets/x-DpTzXQcX.js","assets/doc-browser-context-DfLHAWbG.js","assets/model-config-mfhqEZBG.js","assets/api-C412zuay.js","assets/provider-scoped-model-input-CL9sti2I.js","assets/select-BELPuXLW.js","assets/es2015-BXroVnPi.js","assets/folder-D7-VTnkz.js","assets/loader-circle-B5i8oMMY.js","assets/sparkles-D1ZKWdm4.js","assets/skeleton-CFQRIUzt.js","assets/use-config-CrWZ_TSF.js","assets/config-hints-MogHYQ8G.js","assets/chat-page-BCaNZJGT.js","assets/chat-ChCu7LQD.js","assets/dialog-B-CXiFPZ.js","assets/dist-DYVfg3q5.js","assets/popover-CPUPma-w.js","assets/tooltip-CI0rpNee.js","assets/theme-provider-DeBrTglS.js","assets/refresh-cw-BxojR62w.js","assets/chunk-JZWAC4HX-DvbcIVPf.js","assets/logos-CqVm0q0W.js","assets/refresh-ccw-Bii4w8aB.js","assets/settings-CiRChctQ.js","assets/trash-2-rY9ZteZX.js","assets/doc-browser-BUlCkZo2.js","assets/use-viewport-layout-CWHVDC6z.js","assets/logo-badge-BQgKnVtz.js","assets/mcp-marketplace-page-DuEixgSs.js","assets/use-infinite-scroll-loader-Cw5qQr3-.js","assets/use-confirm-dialog-hbynwWf2.js","assets/notice-card-CozHB03G.js","assets/tag-chip-D9BWWgYg.js","assets/play-D8WJLnJe.js","assets/marketplace-page-C9oZ01rM.js","assets/tabs-custom-CsACkVji.js","assets/search-config-Bcnk9VlL.js","assets/key-round-CnI1mc9F.js","assets/config-split-page-BMRGuCJQ.js","assets/providers-list-HPmL2akJ.js","assets/setting-row-D5DtT6Ny.js","assets/status-dot-Dv_hiUVa.js","assets/channels-list-page-sISO_4Yj.js","assets/hash-zajSTDXZ.js","assets/message-square-D6Z4NwpG.js","assets/runtime-config-page-BCshTAAE.js","assets/rotate-cw-1Xqa7LZ8.js","assets/save--BVI5wZX.js","assets/desktop-update-config-BfJ5iSeY.js","assets/sessions-config-page-CG49_0Z6.js","assets/secrets-config-Dde-5Y1w.js","assets/remote-oDlAdgVA.js","assets/app-manager-provider-Cm-KiZZG.js","assets/marketplace-page-C8uaWkfd.js","assets/mcp-marketplace-page-rNqr6ZpD.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as e,a as t,h as n,i as r,m as i,p as a,u as o}from"./i18n-C5Mibli1.js";import{Bt as s,Ft as c,It as l,Kt as u,Pt as d,St as f,ct as p,dt as m,f as h,mt as g,qt as _,ut as v,xt as y,yt as b}from"./api-C412zuay.js";import{a as x,c as S,i as C,n as ee,o as te,r as w,s as T,t as E}from"./chunk-JZWAC4HX-DvbcIVPf.js";import{_ as ne,c as D,d as O,g as k,h as A,i as j,l as M,m as re,n as ie,o as ae,p as oe,r as se,s as N,t as ce,u as le,v as ue}from"./theme-provider-DeBrTglS.js";import{n as P}from"./search-vChioOoe.js";import{p as de,u as fe}from"./chat-ChCu7LQD.js";import{t as pe}from"./book-open-DgLqYpNY.js";import{k as F,r as I}from"./select-BELPuXLW.js";import{a as L,i as R,n as z,o as B,r as me,s as he,t as ge}from"./app-navigation.config-BORqHkbN.js";import{t as _e}from"./key-round-CnI1mc9F.js";import{h as ve,i as ye,n as be,r as xe,t as Se}from"./app-manager-provider-Cm-KiZZG.js";import{t as Ce}from"./settings-CiRChctQ.js";import{i as V,n as we}from"./doc-browser-context-DfLHAWbG.js";import{n as H,r as Te,t as Ee}from"./doc-browser-BUlCkZo2.js";import{t as U}from"./use-viewport-layout-CWHVDC6z.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var De=n((e=>{var t=_();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),W=e(i(),1),Oe=De(),G=f(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null})),ke=new class{constructor(){this.start=async()=>{let e=this.getDesktopApi();if(!e){this.markUnsupported();return}G.setState({supported:!0,initialized:!1,busyAction:`loading`});try{let t=await e.getPresenceState();G.setState({supported:!0,initialized:!0,busyAction:null,snapshot:t})}catch(e){G.setState({supported:!0,initialized:!0,busyAction:null}),l.error(`${r(`runtimePresenceLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.markUnsupported=()=>{G.setState({supported:!1,initialized:!0,busyAction:null,snapshot:null})},this.updatePreferences=async e=>{let t=this.getDesktopApi();if(!t)throw Error(r(`runtimePresenceLaunchAtLoginUnavailable`));G.setState({busyAction:`saving-preferences`});try{let n=await t.updatePresencePreferences(e);return G.setState({supported:!0,initialized:!0,snapshot:n}),l.success(r(`runtimePresenceSaved`)),n}catch(e){throw l.error(`${r(`runtimePresenceSaveFailed`)}: ${this.getErrorMessage(e)}`),e}finally{G.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:r(`error`)}},K=f(()=>({supported:!1,initialized:!1,busyAction:null,snapshot:null}));new class{constructor(){this.unsubscribe=null,this.subscriptionCount=0,this.start=async()=>{this.subscriptionCount+=1;let e=this.getDesktopApi();if(!e){K.setState({supported:!1,initialized:!0,snapshot:null});return}this.unsubscribe||=e.onUpdateStateChanged(e=>{K.setState({supported:!0,initialized:!0,snapshot:e})}),K.setState({supported:!0,initialized:!1});try{let t=await e.getUpdateState();K.setState({supported:!0,initialized:!0,snapshot:t})}catch(e){K.setState({supported:!0,initialized:!0}),l.error(`${r(`desktopUpdatesLoadFailed`)}: ${this.getErrorMessage(e)}`)}},this.stop=()=>{this.subscriptionCount=Math.max(0,this.subscriptionCount-1),!(this.subscriptionCount>0)&&(this.unsubscribe?.(),this.unsubscribe=null)},this.checkForUpdates=async()=>{let e;try{e=await this.runSnapshotCommand(`checking`,r(`desktopUpdatesCheckFailed`),async e=>await e.checkForUpdates())}catch{return}if(e.status===`up-to-date`){l.success(r(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){l.success(r(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??r(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){l.success(r(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&l.error(e.errorMessage)},this.downloadUpdate=async()=>{let e;try{e=await this.runSnapshotCommand(`downloading`,r(`desktopUpdatesDownloadFailed`),async e=>await e.downloadUpdate())}catch{return}e.status===`downloaded`&&l.success(r(`desktopUpdatesReadyToApply`))},this.applyDownloadedUpdate=async()=>{try{await this.runSnapshotCommand(`applying`,r(`desktopUpdatesApplyFailed`),async e=>await e.applyDownloadedUpdate())}catch{return}},this.updatePreferences=async e=>{try{await this.runSnapshotCommand(`saving-preferences`,r(`desktopUpdatesPreferencesFailed`),async t=>await t.updatePreferences(e))}catch{return}},this.updateChannel=async e=>{if(K.getState().snapshot?.channel===e)return;let t;try{t=await this.runSnapshotCommand(`switching-channel`,r(`desktopUpdatesChannelChangeFailed`),async t=>await t.updateChannel(e))}catch{return}if(t.status===`update-available`&&t.availableVersion){l.success(r(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}l.success(r(`desktopUpdatesChannelChanged`).replace(`{channel}`,this.getChannelLabel(e)))},this.runSnapshotCommand=async(e,t,n)=>{let i=this.getDesktopApi();if(!i)throw Error(r(`desktopUpdatesDesktopOnlyDescription`));K.setState({busyAction:e});try{let e=await n(i);return K.setState({snapshot:e}),e}catch(e){throw l.error(`${t}: ${this.getErrorMessage(e)}`),e}finally{K.setState({busyAction:null})}},this.getDesktopApi=()=>typeof window>`u`?null:window.nextclawDesktop??null,this.getErrorMessage=e=>e instanceof Error?e.message:r(`error`),this.getChannelLabel=e=>r(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}};function q(){let{language:e,setLanguage:n}=H();return{currentLanguage:e,currentLanguageLabel:t.find(t=>t.value===e)?.label??e,languageOptions:t,selectLanguage:(0,W.useCallback)(t=>{e!==t&&(n(t),window.location.reload())},[e,n])}}var J=a();function Ae(){let{currentLanguage:e,currentLanguageLabel:t,languageOptions:n,selectLanguage:i}=q();return(0,J.jsxs)(`section`,{className:`mx-auto w-full max-w-3xl space-y-4`,children:[(0,J.jsx)(`div`,{className:`rounded-3xl border border-gray-200/80 bg-white p-5 shadow-card`,children:(0,J.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,J.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,J.jsx)(A,{className:`h-4 w-4`})}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{className:`text-base font-semibold text-gray-900`,children:r(`language`)}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-gray-500`,children:t})]})]})}),(0,J.jsx)(`div`,{className:`overflow-hidden rounded-3xl border border-gray-200/80 bg-white shadow-card`,children:n.map(t=>{let n=t.value===e;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>i(t.value),className:o(`flex w-full items-center justify-between gap-3 border-b border-gray-100 px-5 py-4 text-left text-sm transition-colors last:border-b-0`,n?`bg-gray-50 text-gray-900`:`text-gray-700 hover:bg-gray-50/70`),"aria-current":n?`true`:void 0,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:t.label}),n?(0,J.jsx)(F,{className:`h-4 w-4 text-gray-700`}):null]},t.value)})})]})}function je({mode:e}){let t=be(),n=V(),i=ve(),{currentLanguage:a,currentLanguageLabel:s,languageOptions:c,selectLanguage:l}=q(),{theme:u,setTheme:d}=ie(),f=e===`settings`,p=r(O.find(e=>e.value===u)?.labelKey??`themeWarm`),m=i.data?.account.email?.trim(),h=!!i.data?.account.loggedIn,g=e=>{u!==e&&d(e)},_=[{target:`/chat`,label:r(`chat`),icon:re},{target:`/chat/cron`,label:r(`cron`),icon:ue},{target:`/chat/skills`,label:r(`marketplaceFilterSkills`),icon:k},{target:`/agents`,label:r(`agentsPageTitle`),icon:ne}],v=me(r),y=f?v:_,b=f?`compact`:`default`;return(0,J.jsxs)(`aside`,{className:`w-[240px] shrink-0 flex h-full min-h-0 flex-col overflow-hidden bg-secondary px-4 py-6`,children:[f?(0,J.jsx)(`div`,{className:`shrink-0 px-2 pb-3`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1`,"data-testid":`settings-sidebar-header`,children:[(0,J.jsxs)(w,{to:`/chat`,className:`group inline-flex min-w-0 items-center gap-1.5 rounded-lg px-1 py-1 text-[12px] font-medium text-gray-500 transition-colors hover:bg-gray-200/60 hover:text-gray-900`,children:[(0,J.jsx)(P,{className:`h-3.5 w-3.5 shrink-0 text-gray-400 group-hover:text-gray-700`}),(0,J.jsx)(`span`,{className:`truncate`,children:r(`backToMain`)})]}),(0,J.jsx)(`span`,{className:`h-4 w-px shrink-0 bg-[#dddfe6]`,"aria-hidden":`true`}),(0,J.jsx)(`h1`,{className:`truncate text-[15px] font-semibold tracking-[-0.01em] text-gray-800`,children:r(`settings`)})]})}):(0,J.jsx)(`div`,{className:`shrink-0 px-2 pb-8`,children:(0,J.jsx)(le,{className:`flex items-center gap-2.5 cursor-pointer`})}),(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsx)(`nav`,{className:`custom-scrollbar min-h-0 flex-1 overflow-y-auto pr-1`,children:(0,J.jsx)(`ul`,{className:o(f?`space-y-0.5 pb-3`:`space-y-1 pb-4`),children:y.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(D,{to:e.target,label:e.label,icon:e.icon,density:b})},e.target))})}),(0,J.jsxs)(`div`,{className:o(`shrink-0 border-t border-[#dde0ea] bg-secondary`,f?`mt-2 pt-3`:`mt-3 pt-3`),children:[f?(0,J.jsx)(N,{onClick:()=>t.accountManager.openAccountPanel(),icon:_e,label:r(`remoteAccountEntryManage`),density:`compact`,className:`mb-1.5`,trailing:h?m||r(`remoteAccountEntryConnected`):r(`remoteAccountEntryDisconnected`),trailingClassName:`max-w-[92px] truncate text-right`,testId:`settings-sidebar-account-entry`,trailingTestId:`settings-sidebar-account-status`}):null,e===`main`&&(0,J.jsx)(`div`,{className:`mb-2`,children:(0,J.jsx)(D,{to:`/settings`,label:r(`settings`),icon:Ce})}),(0,J.jsx)(`div`,{className:`mb-2`,children:(0,J.jsx)(M,{value:u,onValueChange:e=>g(e),icon:oe,label:r(`theme`),valueLabel:p,density:b,children:O.map(e=>(0,J.jsx)(I,{value:e.value,className:`text-xs`,children:r(e.labelKey)},e.value))})}),(0,J.jsx)(`div`,{className:`mb-2`,children:(0,J.jsx)(M,{value:a,onValueChange:e=>l(e),icon:A,label:r(`language`),valueLabel:s,density:b,children:c.map(e=>(0,J.jsx)(I,{value:e.value,className:`text-xs`,children:e.label},e.value))})}),(0,J.jsx)(N,{onClick:()=>n.open(void 0,{kind:`docs`,newTab:!0,title:`Docs`}),icon:pe,label:r(`docBrowserHelp`),density:b})]})]})]})}var Y=(0,W.lazy)(async()=>({default:(await u(async()=>{let{DocBrowser:e}=await import(`./doc-browser-Doh2541x.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function Me({pathname:e,isDocBrowserOpen:t,docBrowserMode:n,children:r}){let i=L(e);return(0,J.jsxs)(`div`,{className:`h-screen flex bg-background font-sans text-foreground`,children:[!i&&(0,J.jsx)(je,{mode:`settings`}),(0,J.jsxs)(`div`,{className:`flex-1 flex min-w-0 overflow-hidden relative`,children:[(0,J.jsx)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:i?(0,J.jsx)(`div`,{className:`flex-1 h-full overflow-hidden`,children:r}):(0,J.jsx)(`main`,{className:`flex-1 overflow-auto p-8 pb-16 custom-scrollbar`,children:(0,J.jsx)(`div`,{className:`mx-auto h-full max-w-6xl animate-fade-in`,children:r})})}),t&&n===`docked`?(0,J.jsx)(W.Suspense,{fallback:null,children:(0,J.jsx)(Y,{})}):null]}),t&&n===`floating`?(0,J.jsx)(W.Suspense,{fallback:null,children:(0,J.jsx)(Y,{})}):null]})}function Ne(e,t){if(t===`/settings`)return B(e);let n=e.toLowerCase(),r=t.toLowerCase();return n===r||n.startsWith(`${r}/`)}function Pe(){let{pathname:e}=T(),t=ge(r);return(0,J.jsx)(`nav`,{"data-testid":`mobile-bottom-nav`,"aria-label":r(`settings`),className:`shrink-0 border-t border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingBottom:`calc(env(safe-area-inset-bottom, 0px) + 0.25rem)`},children:(0,J.jsx)(`ul`,{className:`grid grid-cols-4 gap-1 px-2 pt-1`,children:t.map(t=>{let n=Ne(e,t.target);return(0,J.jsx)(`li`,{children:(0,J.jsx)(ee,{to:t.target,"aria-current":n?`page`:void 0,className:o(`group flex min-h-[2.875rem] items-center justify-center rounded-xl px-1 py-1 text-[10px] font-medium transition-colors`,n?`text-gray-900`:`text-gray-500 hover:text-gray-800`),children:(0,J.jsxs)(`span`,{"data-testid":n?`mobile-nav-active-indicator`:void 0,className:o(`inline-flex max-w-full min-w-14 flex-col items-center justify-center gap-0.5 rounded-xl px-2 py-1 transition-colors`,n?`bg-gray-100`:`bg-transparent group-hover:bg-gray-50`),children:[(0,J.jsx)(t.icon,{className:o(`h-3.5 w-3.5`,n?`text-gray-900`:`text-gray-400`)}),(0,J.jsx)(`span`,{className:`max-w-full truncate`,children:t.label})]})})},t.target)})})})}function Fe(){let e=S(),{pathname:t}=T(),n=he(t,r);return(0,J.jsx)(`header`,{"data-testid":`mobile-topbar`,className:`shrink-0 border-b border-gray-200/80 bg-white/95 backdrop-blur-sm`,style:{paddingTop:`calc(env(safe-area-inset-top, 0px) + 0.25rem)`},children:(0,J.jsxs)(`div`,{className:`flex min-h-[2.75rem] items-center gap-2 px-3 py-1.5`,children:[n.backTarget?(0,J.jsx)(`button`,{type:`button`,onClick:()=>e(n.backTarget),className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-gray-200 text-gray-600 transition-colors hover:bg-gray-50 hover:text-gray-900`,"aria-label":n.backLabel??r(`backToMain`),children:(0,J.jsx)(P,{className:`h-4 w-4`})}):null,(0,J.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,J.jsx)(`h1`,{className:`truncate text-center text-[15px] font-semibold text-gray-900`,children:n.title})}),n.backTarget?(0,J.jsx)(`div`,{className:`h-8 w-8 shrink-0`,"aria-hidden":`true`}):null]})})}var Ie=(0,W.lazy)(async()=>({default:(await u(async()=>{let{DocBrowser:e}=await import(`./doc-browser-Doh2541x.js`);return{DocBrowser:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).DocBrowser}));function Le({pathname:e,isDocBrowserOpen:t,children:n}){let r=L(e),i=!R(e),a=!R(e);return(0,J.jsxs)(`div`,{className:`flex h-[100svh] flex-col bg-background font-sans text-foreground supports-[height:100dvh]:h-[100dvh]`,children:[i?(0,J.jsx)(Fe,{}):null,(0,J.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden`,children:r?(0,J.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden`,children:n}):(0,J.jsx)(`main`,{className:`h-full overflow-auto px-4 py-4 custom-scrollbar`,children:(0,J.jsx)(`div`,{className:`mx-auto max-w-3xl animate-fade-in`,children:n})})}),a?(0,J.jsx)(Pe,{}):null,t?(0,J.jsx)(W.Suspense,{fallback:null,children:(0,J.jsx)(Ie,{displayMode:`fullscreen`})}):null]})}function Re(){let e=z(r);return(0,J.jsx)(`div`,{"data-testid":`mobile-settings-shell`,className:`space-y-3 pb-4`,children:e.map(e=>(0,J.jsxs)(w,{to:e.target,className:({isActive:e})=>o(`flex items-center gap-3 rounded-2xl border border-gray-200/80 bg-white px-4 py-4 shadow-card transition-colors`,e?`border-gray-300 bg-gray-50`:`hover:border-gray-300 hover:bg-gray-50/70`),children:[(0,J.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-2xl bg-gray-100 text-gray-600`,children:(0,J.jsx)(e.icon,{className:`h-4 w-4`})}),(0,J.jsx)(`div`,{className:`min-w-0`,children:(0,J.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.label})})]},e.target))})}function ze(){let{pathname:e}=T(),t=S();return R(e)?(0,J.jsx)(de,{layoutMode:`mobile`,onBackToList:()=>t(`/chat`)}):(0,J.jsx)(fe,{variant:`mobile`})}var Be=`NextClaw`,Ve=[{prefix:`/marketplace/mcp`,key:`marketplaceMcpPageTitle`},{prefix:`/marketplace/plugins`,key:`marketplacePluginsPageTitle`},{prefix:`/marketplace/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/marketplace`,key:`marketplace`},{prefix:`/skills`,key:`marketplaceSkillsPageTitle`},{prefix:`/cron`,key:`cronPageTitle`},{prefix:`/agents`,key:`agentsPageTitle`},{prefix:`/chat`,key:`chat`},{prefix:`/model`,key:`modelPageTitle`},{prefix:`/search`,key:`searchPageTitle`},{prefix:`/providers`,key:`providersPageTitle`},{prefix:`/channels`,key:`channelsPageTitle`},{prefix:`/runtime`,key:`runtimePageTitle`},{prefix:`/updates`,key:`runtimeUpdatesPageTitle`},{prefix:`/remote`,key:`remotePageTitle`},{prefix:`/security`,key:`authSecurityTitle`},{prefix:`/sessions`,key:`sessionsPageTitle`},{prefix:`/secrets`,key:`secretsPageTitle`}];function He(e,t){return e===t||e.startsWith(`${t}/`)}function Ue(e){let t=e.toLowerCase();for(let{prefix:e,key:n}of Ve)if(He(t,e))return r(n);return r(`settings`)}function We(e){return`${Be} - ${Ue(e)}`}function Ge({children:e}){let{isOpen:t,mode:n}=V();Te();let{pathname:r}=T(),{language:i}=H(),{isMobile:a}=U();return(0,W.useEffect)(()=>{document.title=We(r)},[r,i]),a?(0,J.jsx)(Le,{pathname:r,isDocBrowserOpen:t,children:e}):(0,J.jsx)(Me,{pathname:r,isDocBrowserOpen:t,docBrowserMode:n,children:e})}function Ke({children:e}){return(0,J.jsx)(we,{children:(0,J.jsx)(Ge,{children:e})})}function qe(){let{isMobile:e}=U();return e?(0,J.jsx)(Re,{}):(0,J.jsx)(C,{to:`/model`,replace:!0})}function Je(e){let t=e.trim().toLowerCase();return t?!(t.startsWith(`plugins`)||t.startsWith(`skills`)):!0}function Ye(e,t){t.startsWith(`plugins`)&&(e?.invalidateQueries({queryKey:[`ncp-session-types`]}),e?.invalidateQueries({queryKey:[`marketplace-installed`,`plugin`]}),e?.invalidateQueries({queryKey:[`marketplace-items`]})),t.startsWith(`mcp`)&&(e?.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e?.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}))}function Xe(e,t){e&&Je(t)&&e.invalidateQueries({queryKey:[`config`]}),Ye(e,t)}function Ze(e){let{queryClient:t,shouldResyncSessions:n,clearShouldResyncSessions:r,markShouldResyncSessions:i,event:a}=e;if(a.type===`connection.open`){y.handleConnectionRestored(),n&&(r(),t?.invalidateQueries({queryKey:[`ncp-sessions`]}));return}if(a.type===`connection.close`||a.type===`connection.error`){y.handleConnectionInterrupted(a.type===`connection.error`?a.payload?.message:null),i();return}if(a.type===`config.updated`){Xe(t,typeof a.payload?.path==`string`?a.payload.path:``);return}if(a.type===`session.run-status`||a.type===`session.summary.upsert`||a.type===`session.summary.delete`){h(t,a);return}a.type===`error`&&console.error(`Realtime transport error:`,a.payload.message)}function Qe(e){let t=(0,W.useRef)(!1);(0,W.useEffect)(()=>p.subscribe(n=>Ze({queryClient:e,shouldResyncSessions:t.current,clearShouldResyncSessions:()=>{t.current=!1},markShouldResyncSessions:()=>{t.current=!0},event:n})),[e])}var $e=(0,W.lazy)(async()=>({default:(await u(async()=>{let{ModelConfig:e}=await import(`./model-config-mfhqEZBG.js`);return{ModelConfig:e}},__vite__mapDeps([10,2,11,5,3,12,13,14,15,16,17,9,18,19,20]))).ModelConfig})),X=(0,W.lazy)(async()=>({default:(await u(async()=>{let{ChatPage:e}=await import(`./chat-page-BCaNZJGT.js`);return{ChatPage:e}},__vite__mapDeps([21,2,11,13,14,3,22,23,24,8,25,26,27,28,29,19,4,5,6,15,30,16,7,31,32,17,33,34,1,9,35,36,18,12,37,38,39,40,41,42,43,44]))).ChatPage})),et=(0,W.lazy)(async()=>({default:(await u(async()=>{let{SearchConfig:e}=await import(`./search-config-Bcnk9VlL.js`);return{SearchConfig:e}},__vite__mapDeps([45,2,11,13,14,3,4,6,46,35,47,19]))).SearchConfig})),tt=(0,W.lazy)(async()=>({default:(await u(async()=>{let{ProvidersList:e}=await import(`./providers-list-HPmL2akJ.js`);return{ProvidersList:e}},__vite__mapDeps([48,2,11,13,14,3,25,24,4,46,7,33,8,35,36,47,49,50,44,19,20]))).ProvidersList})),nt=(0,W.lazy)(async()=>({default:(await u(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-sISO_4Yj.js`);return{ChannelsList:e}},__vite__mapDeps([51,2,11,13,14,3,4,5,6,30,52,46,16,53,32,8,35,36,47,50,44,41,19,20]))).ChannelsList})),rt=(0,W.lazy)(async()=>({default:(await u(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-BCshTAAE.js`);return{RuntimeConfig:e}},__vite__mapDeps([54,2,11,13,14,3,27,25,24,28,8,29,19,16,42,7,55,56,33,40,49,20]))).RuntimeConfig})),Z=(0,W.lazy)(async()=>({default:(await u(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-BfJ5iSeY.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([57,2,11,13,14,3,28,6,55]))).DesktopUpdateConfig})),it=(0,W.lazy)(async()=>({default:(await u(async()=>{let{SecurityConfig:e}=await import(`./api-C412zuay.js`).then(e=>e.lt);return{SecurityConfig:e}},__vite__mapDeps([11,2]))).SecurityConfig})),at=(0,W.lazy)(async()=>({default:(await u(async()=>{let{SessionsConfig:e}=await import(`./sessions-config-page-CG49_0Z6.js`);return{SessionsConfig:e}},__vite__mapDeps([58,2,11,13,14,3,22,23,24,8,25,26,27,28,29,19,4,5,6,15,30,16,7,31,32,17,33,34,1,9,35,36,18,52,47,39]))).SessionsConfig})),ot=(0,W.lazy)(async()=>({default:(await u(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-Dde-5Y1w.js`);return{SecretsConfig:e}},__vite__mapDeps([59,2,11,13,14,3,7,56,33,19]))).SecretsConfig})),st=(0,W.lazy)(async()=>({default:(await u(async()=>{let{RemoteAccessPage:e}=await import(`./remote-oDlAdgVA.js`);return{RemoteAccessPage:e}},__vite__mapDeps([60,61,2,11,23,14,24,8,3,46,31,40,50]))).RemoteAccessPage})),ct=(0,W.lazy)(async()=>({default:(await u(async()=>{let{MarketplacePage:e}=await import(`./marketplace-page-C8uaWkfd.js`);return{MarketplacePage:e}},__vite__mapDeps([62,43,2,11,26,13,14,3,24,38,18,29,34,1,4,5,6,7,8,9,39,23,44]))).MarketplacePage})),lt=(0,W.lazy)(async()=>({default:(await u(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-rNqr6ZpD.js`);return{McpMarketplacePage:e}},__vite__mapDeps([63,37,2,11,23,14,24,8,3,38,13,18,17,34,1,4,5,6,7,9,39,40,41]))).McpMarketplacePage}));function ut(){return(0,J.jsx)(`div`,{className:`h-full w-full animate-pulse rounded-2xl border border-border/40 bg-card/40`})}function dt({children:e}){return(0,J.jsx)(W.Suspense,{fallback:(0,J.jsx)(ut,{}),children:e})}function Q(e){return(0,J.jsx)(dt,{children:e})}var ft=[{path:`/chat/skills`,redirectTo:`/skills`},{path:`/chat/cron`,redirectTo:`/cron`},{path:`/chat/agents`,redirectTo:`/agents`},{path:`/chat/:sessionId?`,element:Q((0,J.jsx)(X,{view:`chat`}))},{path:`/agents`,element:Q((0,J.jsx)(X,{view:`agents`}))},{path:`/skills`,element:Q((0,J.jsx)(X,{view:`skills`}))},{path:`/cron`,element:Q((0,J.jsx)(X,{view:`cron`}))},{path:`/model`,element:Q((0,J.jsx)($e,{}))},{path:`/search`,element:Q((0,J.jsx)(et,{}))},{path:`/providers`,element:Q((0,J.jsx)(tt,{}))},{path:`/channels`,element:Q((0,J.jsx)(nt,{}))},{path:`/runtime`,element:Q((0,J.jsx)(rt,{}))},{path:`/updates`,element:Q((0,J.jsx)(Z,{}))},{path:`/remote`,element:Q((0,J.jsx)(st,{}))},{path:`/security`,element:Q((0,J.jsx)(it,{}))},{path:`/sessions`,element:Q((0,J.jsx)(at,{}))},{path:`/secrets`,element:Q((0,J.jsx)(ot,{}))},{path:`/language`,element:(0,J.jsx)(Ae,{})},{path:`/settings`,element:(0,J.jsx)(qe,{})},{path:`/marketplace/skills`,redirectTo:`/skills`},{path:`/marketplace`,redirectTo:`/marketplace/plugins`},{path:`/marketplace/mcp`,element:Q((0,J.jsx)(lt,{}))},{path:`/marketplace/:type`,element:Q((0,J.jsx)(ct,{}))},{path:`/`,redirectTo:`/chat`},{path:`*`,redirectTo:`/chat`}];function pt(e){return`redirectTo`in e?(0,J.jsx)(x,{path:e.path,element:(0,J.jsx)(C,{to:e.redirectTo,replace:!0})},e.path):(0,J.jsx)(x,{path:e.path,element:e.element},e.path)}function mt(){return(0,J.jsx)(te,{children:ft.map(pt)})}function $(){return Qe(d),b(),(0,W.useEffect)(()=>(g.start(),()=>{g.stop()}),[]),(0,J.jsxs)(Se,{children:[(0,J.jsx)(Ke,{children:(0,J.jsx)(mt,{})}),(0,J.jsx)(ye,{})]})}function ht(){let e=m(),t=e.isError&&v(e.error);return e.isLoading&&!e.isError||t||e.isError?(0,J.jsx)($,{}):e.data?.enabled&&!e.data.authenticated?(0,J.jsx)(xe,{username:e.data.username}):(0,J.jsx)($,{})}function gt(){return(0,W.useEffect)(()=>{se()},[]),(0,J.jsxs)(s,{client:d,children:[(0,J.jsx)(ht,{}),(0,J.jsx)(j,{}),(0,J.jsx)(ae,{}),(0,J.jsx)(c,{position:`top-right`,richColors:!0})]})}(0,Oe.createRoot)(document.getElementById(`root`)).render((0,J.jsx)(W.StrictMode,{children:(0,J.jsx)(ce,{children:(0,J.jsx)(Ee,{children:(0,J.jsx)(E,{children:(0,J.jsx)(gt,{})})})})}));export{ke as n,G as r,ze as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./marketplace-page-C9oZ01rM.js";export{e as MarketplacePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./mcp-marketplace-page-DuEixgSs.js";export{e as McpMarketplacePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as e}from"./app-manager-provider-Cm-KiZZG.js";export{e as RemoteAccessPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r}from"./i18n-C5Mibli1.js";import{Ct as i,Dt as a,Et as o,It as s,Mt as c,Ot as l,Tt as u,gt as d,jt as f,kt as p,pt as m,vt as h,wt as g,xt as _}from"./api-C412zuay.js";import{t as v}from"./createLucideIcon-BZkY6emz.js";import{a as y}from"./theme-provider-DeBrTglS.js";import{a as b,i as x,n as S,r as C,t as w}from"./select-BELPuXLW.js";import{t as ee}from"./loader-circle-B5i8oMMY.js";import{t as te}from"./play-D8WJLnJe.js";import{t as T}from"./plus-Di0KAkiO.js";import{t as E}from"./rotate-cw-1Xqa7LZ8.js";import{t as ne}from"./save--BVI5wZX.js";import{t as D}from"./trash-2-rY9ZteZX.js";import{t as O}from"./notice-card-CozHB03G.js";import{i as k,n as A,w as j}from"./use-config-CrWZ_TSF.js";import{n as M,r as N}from"./index-CqPDhosM.js";import{t as P}from"./config-hints-MogHYQ8G.js";import{t as F}from"./setting-row-D5DtT6Ny.js";var re=v(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),I=e(n(),1),L=r(),R={healthy:`runtimeControlHealthy`,"starting-service":`runtimeControlStartingService`,"restarting-service":`runtimeControlRestartingService`,"stopping-service":`runtimeControlStoppingService`,"restarting-app":`runtimeControlRestartingApp`,recovering:`runtimeControlRecovering`,failed:`runtimeControlFailed`},z={running:`runtimeControlServiceRunning`,stopped:`runtimeControlServiceStopped`,starting:`runtimeControlServiceStarting`,stopping:`runtimeControlServiceStopping`,restarting:`runtimeControlServiceRestarting`},B={"desktop-embedded":`runtimeControlEnvironmentDesktop`,"managed-local-service":`runtimeControlEnvironmentManagedService`,"self-hosted-web":`runtimeControlEnvironmentSelfHosted`,"shared-web":`runtimeControlEnvironmentSharedWeb`};function V(e){return t(R[e]??`runtimeControlUnavailable`)}function H(e){return t(z[e]??`runtimeControlServiceUnknown`)}function U(e){return t(B[e.environment])}function W(e,t){return t===`start-service`?e?.canStartService:t===`stop-service`?e?.canStopService:e?.canRestartService}function G(e){return e?[{action:`start-service`,capability:e.canStartService,label:t(`runtimeControlStartService`),icon:`play`},{action:`restart-service`,capability:e.canRestartService,label:t(`runtimeControlRestartService`),icon:`rotate`},{action:`stop-service`,capability:e.canStopService,label:t(`runtimeControlStopService`),icon:`square`,variant:`destructive`},{action:`restart-app`,capability:e.canRestartApp,label:t(`runtimeControlRestartApp`),icon:`rotate`,variant:`secondary`}].filter(e=>e.capability.available||!!e.capability.reasonIfUnavailable):[]}function K(e){let{busy:t,icon:n}=e;return t?(0,L.jsx)(ee,{className:`mr-2 h-4 w-4 animate-spin`}):n===`play`?(0,L.jsx)(te,{className:`mr-2 h-4 w-4`}):n===`square`?(0,L.jsx)(re,{className:`mr-2 h-4 w-4`}):(0,L.jsx)(E,{className:`mr-2 h-4 w-4`})}function q(){let{busy:e,busyAction:n,controlView:r,errorMessage:l,pendingRestart:f,visibleLifecycle:p,visibleMessage:m,visibleServiceState:h}=d(),v=G(r??void 0),y=async e=>{let n=W(r,e);if(!n?.available){s.error(n?.reasonIfUnavailable??t(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&n.requiresConfirmation&&!window.confirm(t(`runtimeControlStopServiceConfirm`))))try{let t=await _.runRuntimeControlAction(e);s.success(t.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);s.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}},b=async()=>{if(!r?.canRestartApp.available){s.error(r?.canRestartApp.reasonIfUnavailable??t(`runtimeRestartAppUnavailable`));return}if(window.confirm(t(`runtimeControlRestartAppConfirm`)))try{let e=await _.runRuntimeControlAction(`restart-app`);s.success(e.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);s.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}};return(0,L.jsxs)(i,{children:[(0,L.jsxs)(o,{children:[(0,L.jsx)(a,{children:t(`runtimeControlTitle`)}),(0,L.jsx)(u,{children:t(`runtimeControlDescription`)})]}),(0,L.jsxs)(g,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-gray-200 bg-gray-50 p-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 md:flex-row md:items-center md:justify-between`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:H(h)}),(0,L.jsx)(`div`,{className:`text-xs text-gray-500`,children:r?U(r):t(`runtimeControlLoading`)})]}),(0,L.jsx)(`p`,{className:`text-sm text-gray-600`,children:m}),(0,L.jsx)(`div`,{className:`text-xs text-gray-500`,children:V(p)}),r?.managementHint?(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:r.managementHint}):null,l&&!e?(0,L.jsx)(`p`,{className:`text-sm text-amber-700`,children:l}):null]}),f?(0,L.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-amber-200 bg-amber-50 p-4`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium text-amber-900`,children:t(`runtimeControlPendingRestartTitle`)}),(0,L.jsx)(`p`,{className:`text-sm text-amber-800`,children:t(`runtimeControlPendingRestartDescription`)}),f.changedPaths.length>0?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-amber-700`,children:t(`runtimeControlPendingRestartPaths`)}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.changedPaths.map(e=>(0,L.jsx)(`span`,{className:`rounded-full border border-amber-200 bg-white px-2.5 py-1 text-xs text-amber-800`,children:e},e))})]}):null]}):null,(0,L.jsx)(`div`,{className:`flex flex-col gap-3 md:flex-row md:flex-wrap`,children:v.map(t=>(0,L.jsxs)(c,{type:`button`,variant:t.variant??`default`,onClick:()=>{if(t.action===`restart-app`){b();return}y(t.action)},disabled:!t.capability.available||e,children:[(0,L.jsx)(K,{icon:t.icon,busy:n===t.action}),t.label]},t.action))}),v.filter(e=>!e.capability.available&&e.capability.reasonIfUnavailable).map(e=>(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:e.capability.reasonIfUnavailable},`${e.action}-reason`))]})]})}function J(e){let{description:t,title:n}=e;return(0,L.jsx)(O,{tone:`neutral`,title:n,description:t})}function Y(e){let{children:n}=e;return(0,L.jsxs)(i,{children:[(0,L.jsxs)(o,{children:[(0,L.jsx)(a,{children:t(`runtimePresenceTitle`)}),(0,L.jsx)(u,{children:t(`runtimePresenceDescription`)})]}),(0,L.jsx)(g,{children:n})]})}function X(){let e=h().runtimeControlView?.environment,n=N(e=>e.supported),r=N(e=>e.initialized),i=N(e=>e.busyAction),a=N(e=>e.snapshot);return(0,I.useEffect)(()=>{if(e===`desktop-embedded`){M.start();return}M.markUnsupported()},[e]),e===`desktop-embedded`?(0,L.jsx)(Y,{children:(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(O,{tone:`neutral`,title:t(`runtimePresenceBehaviorLabel`),description:a?.closeToBackground?t(`runtimePresenceBehaviorBackground`):t(`runtimePresenceBehaviorQuit`),className:`rounded-xl`}),!r||n&&!a?(0,L.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceLoading`)}):null,a?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsx)(F,{title:t(`runtimePresenceCloseToBackground`),description:t(`runtimePresenceCloseToBackgroundHelp`),control:(0,L.jsx)(m,{id:`runtime-presence-close-background`,"aria-label":t(`runtimePresenceCloseToBackground`),checked:a.closeToBackground,disabled:i===`saving-preferences`,onCheckedChange:e=>{M.updatePreferences({closeToBackground:e})}})}),(0,L.jsx)(F,{title:t(`runtimePresenceLaunchAtLogin`),description:a.supportsLaunchAtLogin?t(`runtimePresenceLaunchAtLoginHelp`):a.launchAtLoginReason??t(`runtimePresenceLaunchAtLoginUnavailable`),control:(0,L.jsx)(m,{id:`runtime-presence-launch-login`,"aria-label":t(`runtimePresenceLaunchAtLogin`),checked:a.launchAtLogin,disabled:!a.supportsLaunchAtLogin||i===`saving-preferences`,onCheckedChange:e=>{M.updatePreferences({launchAtLogin:e})}})})]}):null]})}):e===`managed-local-service`?(0,L.jsx)(Y,{children:(0,L.jsx)(J,{title:t(`runtimePresenceManagedLocalTitle`),description:t(`runtimePresenceManagedLocalDescription`)})}):e===`self-hosted-web`?(0,L.jsx)(Y,{children:(0,L.jsx)(J,{title:t(`runtimePresenceSelfHostedTitle`),description:t(`runtimePresenceSelfHostedDescription`)})}):e===`shared-web`?(0,L.jsx)(Y,{children:(0,L.jsx)(J,{title:t(`runtimePresenceSharedTitle`),description:t(`runtimePresenceSharedDescription`)})}):(0,L.jsx)(Y,{children:(0,L.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimePresenceLoading`)})})}function ie(){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(l,{title:t(`runtimePageTitle`),description:t(`runtimePageDescription`)}),(0,L.jsx)(q,{}),(0,L.jsx)(X,{}),(0,L.jsx)(y,{})]})}var Z={wireDialect:`acp`,processScope:`per-session`,command:``,args:[`acp`],env:{},cwd:``,startupTimeoutMs:8e3,probeTimeoutMs:3e3,requestTimeoutMs:12e4};function ae(){return{id:``,default:!1,workspace:``,model:``,runtime:``,contextTokens:void 0,maxToolIterations:void 0}}function oe(){return{agentId:``,match:{channel:``,accountId:``}}}function se(){return{id:``,enabled:!0,label:``,type:`narp-stdio`,config:Z,configText:JSON.stringify(Z,null,2)}}function ce(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,maxToolIterations:e.maxToolIterations}}function le(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 Q(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);return Number.isFinite(n)?n:void 0}function $(e){return{companionEnabled:e.companion?.enabled===!0,agents:(e.agents.list??[]).map(ce),bindings:(e.bindings??[]).map(le),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 ue(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)),typeof e.maxToolIterations==`number`&&(t.maxToolIterations=e.maxToolIterations),t}function de(e){let n=e.agents.map((e,n)=>{if(!e.id.trim())throw Error(t(`agentIdRequiredError`).replace(`{index}`,String(n)));return ue(e)}),r=n.map(e=>e.id).filter((e,t,n)=>n.indexOf(e)!==t);if(r.length>0)throw Error(`${t(`duplicateAgentId`)}: ${r[0]}`);let i=e.bindings.map((n,r)=>{let i=n.agentId.trim(),a=n.match.channel.trim(),o=n.match.accountId?.trim()??``,s=n.match.peer?.kind,c=n.match.peer?.id?.trim()??``;if(!i)throw Error(t(`bindingAgentIdRequired`).replace(`{index}`,String(r)));if(!e.knownAgentIds.has(i))throw Error(`${t(`bindingAgentIdNotFound`).replace(`{index}`,String(r))}: ${i}`);if(!a)throw Error(t(`bindingChannelRequired`).replace(`{index}`,String(r)));let l={agentId:i,match:{channel:a}};if(o&&(l.match.accountId=o),s){if(!c)throw Error(t(`bindingPeerIdRequired`).replace(`{index}`,String(r)));l.match.peer={kind:s,id:c}}return l}),a=e.runtimeEntries.reduce((e,t,n)=>{let r=t.id.trim(),i=t.type.trim();if(!r)throw Error(`Runtime entry id is required at index ${n}.`);if(!i)throw Error(`Runtime entry type is required for "${r}".`);if(e[r])throw Error(`Duplicate runtime entry id: ${r}`);let a=t.configText.trim()?JSON.parse(t.configText):{};if(a&&(typeof a!=`object`||Array.isArray(a)))throw Error(`Runtime entry config for "${r}" must be a JSON object.`);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:n,runtimes:{entries:a}},bindings:i,session:{dmScope:e.dmScope}}}function fe(e){return(0,L.jsxs)(i,{children:[(0,L.jsxs)(o,{children:[(0,L.jsx)(a,{children:e.label??t(`agentList`)}),(0,L.jsx)(u,{children:e.help??t(`agentListHelp`)})]}),(0,L.jsxs)(g,{className:`space-y-3`,children:[e.agents.map((n,r)=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,L.jsx)(f,{value:n.id,onChange:t=>e.onUpdateAgent(r,{id:t.target.value}),placeholder:t(`agentIdPlaceholder`)}),(0,L.jsx)(f,{value:n.workspace??``,onChange:t=>e.onUpdateAgent(r,{workspace:t.target.value}),placeholder:t(`workspaceOverridePlaceholder`)}),(0,L.jsx)(f,{value:n.model??``,onChange:t=>e.onUpdateAgent(r,{model:t.target.value}),placeholder:t(`modelOverridePlaceholder`)}),(0,L.jsx)(f,{value:n.runtime??n.engine??``,onChange:t=>e.onUpdateAgent(r,{runtime:t.target.value}),placeholder:e.engineLabel??t(`engineOverridePlaceholder`)}),(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-2`,children:[(0,L.jsx)(f,{type:`number`,min:1e3,step:1e3,value:n.contextTokens??``,onChange:t=>e.onUpdateAgent(r,{contextTokens:Q(t.target.value)}),placeholder:e.contextTokensLabel??t(`contextTokensPlaceholder`)}),(0,L.jsx)(f,{type:`number`,min:1,value:n.maxToolIterations??``,onChange:t=>e.onUpdateAgent(r,{maxToolIterations:Q(t.target.value)}),placeholder:t(`maxToolsPlaceholder`)})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-600`,children:[(0,L.jsx)(m,{checked:!!n.default,onCheckedChange:t=>e.onSetDefaultAgent(r,t)}),(0,L.jsx)(`span`,{children:t(`defaultAgent`)})]}),(0,L.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e.onRemoveAgent(r),children:[(0,L.jsx)(D,{className:`h-4 w-4 mr-1`}),t(`remove`)]})]})]},`${r}-${n.id}`)),(0,L.jsxs)(c,{type:`button`,variant:`outline`,onClick:e.onAddAgent,children:[(0,L.jsx)(T,{className:`h-4 w-4 mr-2`}),t(`addAgent`)]})]})]})}function pe(e){return(0,L.jsxs)(i,{children:[(0,L.jsxs)(o,{children:[(0,L.jsx)(a,{children:e.label??t(`bindings`)}),(0,L.jsx)(u,{children:e.help??t(`bindingsHelp`)})]}),(0,L.jsxs)(g,{className:`space-y-3`,children:[e.bindings.map((n,r)=>{let i=n.match.peer?.kind??``;return(0,L.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[(0,L.jsx)(f,{value:n.agentId,onChange:t=>e.onUpdateBinding(r,{...n,agentId:t.target.value}),placeholder:t(`targetAgentIdPlaceholder`)}),(0,L.jsx)(f,{value:n.match.channel,onChange:t=>e.onUpdateBinding(r,{...n,match:{...n.match,channel:t.target.value}}),placeholder:t(`channelPlaceholder`)}),(0,L.jsx)(f,{value:n.match.accountId??``,onChange:t=>e.onUpdateBinding(r,{...n,match:{...n.match,accountId:t.target.value}}),placeholder:t(`accountIdOptionalPlaceholder`)}),(0,L.jsxs)(w,{value:i||`__none__`,onValueChange:t=>{let i=t===`__none__`?``:t;e.onUpdateBinding(r,i?{...n,match:{...n.match,peer:{kind:i,id:n.match.peer?.id??``}}}:{...n,match:{...n.match,peer:void 0}})},children:[(0,L.jsx)(x,{children:(0,L.jsx)(b,{})}),(0,L.jsxs)(S,{children:[(0,L.jsx)(C,{value:`__none__`,children:t(`peerKindOptional`)}),(0,L.jsx)(C,{value:`direct`,children:`direct`}),(0,L.jsx)(C,{value:`group`,children:`group`}),(0,L.jsx)(C,{value:`channel`,children:`channel`})]})]}),(0,L.jsx)(f,{value:n.match.peer?.id??``,onChange:t=>e.onUpdateBinding(r,{...n,match:{...n.match,peer:i?{kind:i,id:t.target.value}:void 0}}),placeholder:t(`peerIdPlaceholder`)})]}),(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsxs)(c,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e.onRemoveBinding(r),children:[(0,L.jsx)(D,{className:`h-4 w-4 mr-1`}),t(`remove`)]})})]},`${r}-${n.agentId}`)}),(0,L.jsxs)(c,{type:`button`,variant:`outline`,onClick:e.onAddBinding,children:[(0,L.jsx)(T,{className:`h-4 w-4 mr-2`}),t(`addBinding`)]})]})]})}function me(e){return(0,L.jsxs)(i,{children:[(0,L.jsxs)(o,{children:[(0,L.jsx)(a,{children:e.label??`Runtime Entries`}),(0,L.jsx)(u,{children:e.help??`统一管理可见的 runtime entry 与其配置。`})]}),(0,L.jsxs)(g,{className:`space-y-3`,children:[e.entries.map((t,n)=>(0,L.jsxs)(`div`,{className:`rounded-xl border border-gray-200 p-3 space-y-3`,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,L.jsx)(f,{value:t.id,onChange:t=>e.onUpdateEntry(n,{id:t.target.value}),placeholder:`entry id,例如 hermes`}),(0,L.jsx)(f,{value:t.label??``,onChange:t=>e.onUpdateEntry(n,{label:t.target.value}),placeholder:`展示名称,例如 Hermes`}),(0,L.jsx)(f,{value:t.type,onChange:t=>e.onUpdateEntry(n,{type:t.target.value}),placeholder:`runtime type,例如 narp-stdio`}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-gray-200 px-3 py-2`,children:[(0,L.jsx)(`span`,{className:`text-sm text-gray-700`,children:`Enabled`}),(0,L.jsx)(m,{checked:t.enabled!==!1,onCheckedChange:t=>e.onUpdateEntry(n,{enabled:t})})]})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:`Config JSON`}),(0,L.jsx)(`textarea`,{className:`min-h-32 w-full rounded-md border border-gray-200 px-3 py-2 text-sm font-mono`,value:t.configText,onChange:t=>e.onUpdateEntry(n,{configText:t.target.value}),spellCheck:!1})]}),(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsxs)(c,{type:`button`,variant:`outline`,onClick:()=>e.onRemoveEntry(n),children:[(0,L.jsx)(D,{className:`mr-2 h-4 w-4`}),`Delete`]})})]},`${n}-${t.id||`runtime-entry`}`)),(0,L.jsxs)(c,{type:`button`,variant:`outline`,onClick:e.onAddEntry,children:[(0,L.jsx)(T,{className:`mr-2 h-4 w-4`}),`Add Runtime Entry`]})]})]})}var he=[{value:`main`,label:`main`},{value:`per-peer`,label:`per-peer`},{value:`per-channel-peer`,label:`per-channel-peer`},{value:`per-account-channel-peer`,label:`per-account-channel-peer`}];function ge(e){return(0,L.jsxs)(i,{children:[(0,L.jsxs)(o,{children:[(0,L.jsx)(a,{children:e.dmScopeLabel??t(`dmScope`)}),(0,L.jsx)(u,{children:e.dmScopeHelp??t(`dmScopeHelp`)})]}),(0,L.jsxs)(g,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-md border border-gray-200 px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.companionEnabledLabel??t(`runtimeCompanionEnabled`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:e.companionEnabledHelp??t(`runtimeCompanionEnabledHelp`)})]}),(0,L.jsx)(m,{checked:e.companionEnabled,onCheckedChange:e.onCompanionEnabledChange})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:e.defaultContextTokensLabel??t(`defaultContextTokens`)}),(0,L.jsx)(f,{type:`number`,min:1e3,step:1e3,value:e.defaultContextTokens,onChange:t=>e.onDefaultContextTokensChange(Math.max(1e3,Number.parseInt(t.target.value,10)||1e3))}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:e.defaultContextTokensHelp??t(`defaultContextTokensHelp`)})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:e.defaultEngineLabel??t(`defaultEngine`)}),(0,L.jsx)(f,{value:e.defaultEngine,onChange:t=>e.onDefaultEngineChange(t.target.value),placeholder:t(`defaultEnginePlaceholder`)}),(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:e.defaultEngineHelp??t(`defaultEngineHelp`)})]}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:e.dmScopeLabel??t(`dmScope`)}),(0,L.jsxs)(w,{value:e.dmScope,onValueChange:t=>e.onDmScopeChange(t),children:[(0,L.jsx)(x,{children:(0,L.jsx)(b,{})}),(0,L.jsx)(S,{children:he.map(e=>(0,L.jsx)(C,{value:e.value,children:e.label},e.value))})]})]})]})]})}function _e(e){let n=(0,I.useMemo)(()=>$(e.config),[e.config]),[r,i]=(0,I.useState)(n.agents),[a,o]=(0,I.useState)(n.bindings),[l,u]=(0,I.useState)(n.runtimeEntries),[d,f]=(0,I.useState)(n.dmScope),[m,h]=(0,I.useState)(n.companionEnabled),[g,_]=(0,I.useState)(n.defaultContextTokens),[v,y]=(0,I.useState)(n.defaultEngine),b=(0,I.useMemo)(()=>{let e=new Set([`main`]);return r.forEach(t=>{let n=t.id.trim();n&&e.add(n)}),e},[r]);return(0,L.jsxs)(p,{className:`space-y-6`,children:[(0,L.jsx)(ie,{}),(0,L.jsx)(ge,{companionEnabled:m,dmScope:d,defaultContextTokens:g,defaultEngine:v,onCompanionEnabledChange:h,onDmScopeChange:f,onDefaultContextTokensChange:_,onDefaultEngineChange:y,companionEnabledLabel:P(`companion.enabled`,e.uiHints)?.label,companionEnabledHelp:P(`companion.enabled`,e.uiHints)?.help,dmScopeLabel:P(`session.dmScope`,e.uiHints)?.label,dmScopeHelp:P(`session.dmScope`,e.uiHints)?.help,defaultContextTokensLabel:P(`agents.defaults.contextTokens`,e.uiHints)?.label,defaultContextTokensHelp:P(`agents.defaults.contextTokens`,e.uiHints)?.help,defaultEngineLabel:P(`agents.defaults.engine`,e.uiHints)?.label,defaultEngineHelp:P(`agents.defaults.engine`,e.uiHints)?.help}),(0,L.jsx)(me,{entries:l,onUpdateEntry:(e,t)=>u(n=>n.map((n,r)=>r===e?{...n,...t}:n)),onRemoveEntry:e=>u(t=>t.filter((t,n)=>n!==e)),onAddEntry:()=>u(e=>[...e,se()]),label:P(`agents.runtimes.entries`,e.uiHints)?.label,help:P(`agents.runtimes.entries`,e.uiHints)?.help}),(0,L.jsx)(fe,{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,ae()]),onSetDefaultAgent:(e,t)=>i(n=>t?n.map((t,n)=>({...t,default:n===e})):n.map((t,n)=>n===e?{...t,default:!1}:t)),label:P(`agents.list`,e.uiHints)?.label,help:P(`agents.list`,e.uiHints)?.help,contextTokensLabel:P(`agents.list.*.contextTokens`,e.uiHints)?.label,engineLabel:P(`agents.list.*.engine`,e.uiHints)?.label}),(0,L.jsx)(pe,{bindings:a,onUpdateBinding:(e,t)=>{o(n=>n.map((n,r)=>r===e?t:n))},onRemoveBinding:e=>o(t=>t.filter((t,n)=>n!==e)),onAddBinding:()=>o(e=>[...e,oe()]),label:P(`bindings`,e.uiHints)?.label,help:P(`bindings`,e.uiHints)?.help}),(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsxs)(c,{type:`button`,onClick:()=>{try{let t=de({companionEnabled:m,agents:r,bindings:a,runtimeEntries:l,dmScope:d,defaultContextTokens:g,defaultEngine:v,knownAgentIds:b});e.updateRuntime.mutate({data:t})}catch(e){s.error(e instanceof Error?e.message:String(e))}},disabled:e.updateRuntime.isPending,children:[(0,L.jsx)(ne,{className:`h-4 w-4 mr-2`}),e.updateRuntime.isPending?t(`saving`):t(`saveRuntimeSettings`)]})})]})}function ve(){let{data:e,isLoading:n}=A(),{data:r}=k(),i=j();return n||!e?(0,L.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`runtimeLoading`)}):(0,L.jsx)(_e,{config:e,uiHints:r?.uiHints,updateRuntime:i})}export{ve as RuntimeConfig};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./i18n-C5Mibli1.js";import{$ as t,B as n,F as r,G as i,I as a,It as o,J as s,K as c,L as l,Lt as u,N as d,P as f,Q as p,R as m,Rt as h,U as g,V as _,Vt as v,W as y,X as b,Y as x,Z as S,_ as C,et as w,g as T,h as E,m as D,p as O,q as k,v as A,y as j,z as M}from"./api-C412zuay.js";function ee(){return h({queryKey:[`config`],queryFn:m,staleTime:3e4,refetchOnWindowFocus:!0})}function N(){return h({queryKey:[`app-meta`],queryFn:l,staleTime:1/0})}function P(){return h({queryKey:[`config-meta`],queryFn:M,staleTime:1/0})}function F(){return h({queryKey:[`config-schema`],queryFn:n,staleTime:1/0})}function I(){let t=v();return u({mutationFn:b,onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),o.success(e(`configSaved`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function L(){let n=v();return u({mutationFn:({data:e})=>t(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`config`]}),n.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function R(){let t=v();return u({mutationFn:({provider:e,data:t})=>S(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSaved`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function z(){let t=v();return u({mutationFn:({data:e})=>d(e??{}),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSaved`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function B(){let t=v();return u({mutationFn:({provider:e})=>r(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSaved`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function V(){return u({mutationFn:({provider:e,data:t})=>s(e,t)})}function H(){return u({mutationFn:({provider:e,data:t})=>k(e,t)})}function U(){return u({mutationFn:({provider:e,data:t})=>y(e,t)})}function W(){return u({mutationFn:({provider:e})=>g(e)})}function G(){let t=v();return u({mutationFn:({channel:e,data:t})=>x(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),o.success(e(`configSavedApplying`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function K(){let t=v();return u({mutationFn:({data:e})=>p(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function q(){let t=v();return u({mutationFn:({data:e})=>w(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function J(){return u({mutationFn:({actionId:e,data:t})=>a(e,t),onError:t=>{o.error(e(`error`)+`: `+t.message)}})}function Y(e){return h({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>A(e),staleTime:5e3,retry:!1})}function X(e,t=200){return h({queryKey:[`ncp-session-messages`,e,t],queryFn:()=>T(e,t),enabled:!!e,staleTime:5e3,retry:!1})}function Z(e){return h({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>C(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Q(){let t=v();return u({mutationFn:({sessionId:e})=>E(e),onSuccess:(n,r)=>{O(t,r.sessionId),t.removeQueries({queryKey:[`ncp-session-messages`,r.sessionId]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function $(){let t=v();return u({mutationFn:({sessionId:e,data:t})=>j(e,t),onSuccess:n=>{D(t,n),t.invalidateQueries({queryKey:[`ncp-session-skills`,n.sessionId]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function te(e={all:!0}){return h({queryKey:[`cron`,e],queryFn:()=>_(e),staleTime:1e4})}function ne(){let t=v();return u({mutationFn:({id:e})=>f(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function re(){let t=v();return u({mutationFn:({id:e,enabled:t})=>c(e,{enabled:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}function ie(){let t=v();return u({mutationFn:({id:e,force:t})=>i(e,{force:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),o.success(e(`configSavedApplied`))},onError:t=>{o.error(e(`configSaveFailed`)+`: `+t.message)}})}export{R as C,q as E,$ as S,L as T,H as _,z as a,G as b,Q as c,W as d,X as f,ie as g,U as h,F as i,B as l,Y as m,ee as n,te as o,Z as p,P as r,ne as s,N as t,J as u,V as v,K as w,I as x,re as y};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { api } from "./client";
|
|
2
|
-
import type { AgentCreateRequest, AgentDeleteResult, AgentProfileView, AgentUpdateRequest } from "./types";
|
|
3
|
-
|
|
4
|
-
export async function fetchAgents(): Promise<{ agents: AgentProfileView[] }> {
|
|
5
|
-
const response = await api.get<{ agents: AgentProfileView[] }>("/api/agents");
|
|
6
|
-
if (!response.ok) {
|
|
7
|
-
throw new Error(response.error.message);
|
|
8
|
-
}
|
|
9
|
-
return response.data;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function createAgent(data: AgentCreateRequest): Promise<AgentProfileView> {
|
|
13
|
-
const response = await api.post<AgentProfileView>("/api/agents", data);
|
|
14
|
-
if (!response.ok) {
|
|
15
|
-
throw new Error(response.error.message);
|
|
16
|
-
}
|
|
17
|
-
return response.data;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export async function updateAgent(agentId: string, data: AgentUpdateRequest): Promise<AgentProfileView> {
|
|
21
|
-
const response = await api.put<AgentProfileView>(`/api/agents/${encodeURIComponent(agentId)}`, data);
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
throw new Error(response.error.message);
|
|
24
|
-
}
|
|
25
|
-
return response.data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function deleteAgent(agentId: string): Promise<AgentDeleteResult> {
|
|
29
|
-
const response = await api.delete<AgentDeleteResult>(`/api/agents/${encodeURIComponent(agentId)}`);
|
|
30
|
-
if (!response.ok) {
|
|
31
|
-
throw new Error(response.error.message);
|
|
32
|
-
}
|
|
33
|
-
return response.data;
|
|
34
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { api } from './client';
|
|
2
|
-
import type {
|
|
3
|
-
ChannelAuthPollRequest,
|
|
4
|
-
ChannelAuthPollResult,
|
|
5
|
-
ChannelAuthStartRequest,
|
|
6
|
-
ChannelAuthStartResult
|
|
7
|
-
} from './channel-auth.types';
|
|
8
|
-
|
|
9
|
-
export async function startChannelAuth(
|
|
10
|
-
channel: string,
|
|
11
|
-
data: ChannelAuthStartRequest = {}
|
|
12
|
-
): Promise<ChannelAuthStartResult> {
|
|
13
|
-
const response = await api.post<ChannelAuthStartResult>(
|
|
14
|
-
`/api/config/channels/${channel}/auth/start`,
|
|
15
|
-
data
|
|
16
|
-
);
|
|
17
|
-
if (!response.ok) {
|
|
18
|
-
throw new Error(response.error.message);
|
|
19
|
-
}
|
|
20
|
-
return response.data;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function pollChannelAuth(
|
|
24
|
-
channel: string,
|
|
25
|
-
data: ChannelAuthPollRequest
|
|
26
|
-
): Promise<ChannelAuthPollResult> {
|
|
27
|
-
const response = await api.post<ChannelAuthPollResult>(
|
|
28
|
-
`/api/config/channels/${channel}/auth/poll`,
|
|
29
|
-
data
|
|
30
|
-
);
|
|
31
|
-
if (!response.ok) {
|
|
32
|
-
throw new Error(response.error.message);
|
|
33
|
-
}
|
|
34
|
-
return response.data;
|
|
35
|
-
}
|