@nextclaw/ui 0.12.20-beta.3 → 0.12.20-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +124 -0
- package/dist/assets/api-Dai6UR3J.js +15 -0
- package/dist/assets/app-manager-provider-BZr5VxCe.js +1 -0
- package/dist/assets/{app-navigation.config-BOVDFMnp.js → app-navigation.config-BjIj_FLm.js} +1 -1
- package/dist/assets/channels-list-page-L6FFtRYn.js +8 -0
- package/dist/assets/{chat-ahMH_i_K.js → chat-ZQIVJChB.js} +6 -6
- package/dist/assets/{chat-page-BxlXY-MB.js → chat-page-CR1yI96r.js} +1 -1
- package/dist/assets/desktop-update-config-AXzb7OEa.js +1 -0
- package/dist/assets/{dialog-csshWetU.js → dialog-DgybjpeU.js} +1 -1
- package/dist/assets/{dist-Bl94Ahwx.js → dist-CxcPOISF.js} +1 -1
- package/dist/assets/{es2015-JCM5-KtW.js → es2015-BVRlEE06.js} +1 -1
- package/dist/assets/index-B7RsQ-ne.js +2 -0
- package/dist/assets/marketplace-page-Bj55-6F2.js +1 -0
- package/dist/assets/{marketplace-page-DxlxHCFm.js → marketplace-page-ClRW-W3g.js} +2 -2
- package/dist/assets/mcp-marketplace-page-DtngnIi0.js +40 -0
- package/dist/assets/mcp-marketplace-page-_Wu2VnHy.js +1 -0
- package/dist/assets/{model-config-PccJ9XyH.js → model-config-D_y8F0j6.js} +1 -1
- package/dist/assets/{notice-card-CCgk6FvF.js → notice-card-uzwjFyML.js} +1 -1
- package/dist/assets/{popover-YAsxDBhY.js → popover-C8tMB7tR.js} +1 -1
- package/dist/assets/{provider-scoped-model-input-CzpF7cug.js → provider-scoped-model-input-ORZutTDv.js} +1 -1
- package/dist/assets/{providers-list-8qDMER8o.js → providers-list-DSc3d8me.js} +1 -1
- package/dist/assets/remote-rWiu3cys.js +1 -0
- package/dist/assets/runtime-config-page-B4uSax1I.js +1 -0
- package/dist/assets/{search-config-D3a65l3r.js → search-config-CaqqlsdW.js} +1 -1
- package/dist/assets/{secrets-config-CoMlR_7i.js → secrets-config-llf5ROde.js} +2 -2
- package/dist/assets/{select-DIZrwsKU.js → select-uO-zhYsH.js} +1 -1
- package/dist/assets/{sessions-config-page-QjH5tgjr.js → sessions-config-page-BqOXte9x.js} +2 -2
- package/dist/assets/{setting-row-DiQyrE81.js → setting-row-BIiXR4hx.js} +1 -1
- package/dist/assets/{tag-chip-C3wDBe_-.js → tag-chip-DVbgpsYW.js} +1 -1
- package/dist/assets/{theme-provider-W704JWF8.js → theme-provider-BU77FNSB.js} +1 -1
- package/dist/assets/{tooltip-Dq5Xehpk.js → tooltip-CvAtG-kT.js} +1 -1
- package/dist/assets/use-config-D2QgG7qc.js +1 -0
- package/dist/assets/{use-confirm-dialog-DBoV5n5P.js → use-confirm-dialog-BBClFV8E.js} +1 -1
- package/dist/assets/{use-infinite-scroll-loader-JAicqVC5.js → use-infinite-scroll-loader-CWzpUecQ.js} +1 -1
- package/dist/assets/{use-viewport-layout-BX3XqzJ4.js → use-viewport-layout-C6EN0_eq.js} +1 -1
- package/dist/index.html +15 -15
- package/package.json +9 -9
- package/src/app/hooks/use-app-event-consumers.ts +89 -0
- package/src/app/index.tsx +2 -2
- package/src/features/channels/components/config/channel-form.tsx +7 -9
- package/src/features/system-status/components/desktop-update-config.test.tsx +25 -1
- package/src/features/system-status/components/desktop-update-config.tsx +0 -7
- package/src/features/system-status/managers/runtime-update.manager.ts +18 -20
- package/src/shared/lib/transport/transport.types.ts +2 -2
- package/tsconfig.json +2 -1
- package/vite.config.ts +4 -2
- package/vitest.config.ts +4 -2
- package/dist/assets/api-BcqDx0tm.js +0 -15
- package/dist/assets/app-manager-provider-DVYBjif-.js +0 -1
- package/dist/assets/channels-list-page-CsoI4OJm.js +0 -8
- package/dist/assets/desktop-update-config-CD6-2PfI.js +0 -1
- package/dist/assets/index-CM-57d8J.js +0 -2
- package/dist/assets/marketplace-page-DJGDpTAo.js +0 -1
- package/dist/assets/mcp-marketplace-page-5UjYRWOR.js +0 -40
- package/dist/assets/mcp-marketplace-page-C1XaHZZO.js +0 -1
- package/dist/assets/remote-D4TtLPAp.js +0 -1
- package/dist/assets/runtime-config-page-DWJHrV7H.js +0 -1
- package/dist/assets/use-config-BQJjq1mP.js +0 -1
- package/src/app/hooks/use-realtime-query-bridge.ts +0 -105
|
@@ -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,Ft as l,Lt as u,Nt as d,Ot as f,St as p,Tt as m,a as h,bt as g,c as _,i as ee,jt as v,kt as te,l as y,o as ne,r as b,s as re,u as x,ut as S,wt as C}from"./api-BcqDx0tm.js";import{a as w,n as ie,o as ae,r as oe,t as T}from"./dialog-csshWetU.js";import{t as E}from"./createLucideIcon-BZkY6emz.js";import{t as se}from"./key-round-CnI1mc9F.js";import{t as ce}from"./refresh-ccw-Bii4w8aB.js";import{t as D}from"./notice-card-CCgk6FvF.js";import{t as O}from"./status-dot-Dv_hiUVa.js";var k=E(`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`}]]),A=E(`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`}]]),j=E(`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 M(){return u({queryKey:I,queryFn:h,staleTime:5e3,refetchOnWindowFocus:!0})}var N=e(n(),1),P=i();function F(e){let{label:t,muted:n,value:r}=e;return(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,P.jsx)(`span`,{className:`text-gray-500`,children:t}),(0,P.jsx)(`span`,{className:n?`text-right text-gray-500`:`text-right text-gray-900`,children:r==null||r===``?`-`:String(r)})]})}function le(){let e=$(),n=M(),i=n.data,a=W(e=>e.actionLabel),l=(0,N.useMemo)(()=>J(i),[i]),u=!!a,d=i?.runtime?.deviceName?.trim()||i?.settings.deviceName?.trim()||t(`remoteDeviceNameAuto`),h=!!(i?.account.loggedIn&&U(i)),{hero:g,issueHint:_}=l;return(0,N.useEffect)(()=>{e.remoteAccessManager.syncStatus(i)},[e,i]),n.isLoading&&!i?(0,P.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`remoteLoading`)}):(0,P.jsxs)(f,{className:`space-y-6`,children:[(0,P.jsx)(s,{title:t(`remotePageTitle`),description:t(`remotePageDescription`)}),(0,P.jsxs)(`div`,{className:`grid gap-6 xl:grid-cols-[1.2fr_0.8fr]`,children:[(0,P.jsxs)(p,{children:[(0,P.jsxs)(m,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,P.jsx)(c,{children:g.title}),(0,P.jsx)(O,{status:g.badgeStatus,label:g.badgeLabel})]}),(0,P.jsx)(C,{children:g.description})]}),(0,P.jsxs)(o,{className:`space-y-5`,children:[(0,P.jsxs)(D,{tone:`neutral`,children:[(0,P.jsx)(F,{label:t(`remoteSignedInAccount`),value:i?.account.email}),(0,P.jsx)(F,{label:t(`remoteDeviceName`),value:d}),(0,P.jsx)(F,{label:t(`remoteConnectionStatus`),value:g.badgeLabel}),(0,P.jsx)(F,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[l.primaryAction?(0,P.jsxs)(v,{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:u,children:[l.primaryAction.showRefreshIcon?(0,P.jsx)(ce,{className:`mr-2 h-4 w-4`}):null,a||l.primaryAction.label]}):null,(0,P.jsxs)(v,{variant:`outline`,onClick:()=>void e.accountManager.openNextClawWeb(),disabled:u||!h,children:[(0,P.jsx)(j,{className:`mr-2 h-4 w-4`}),t(`remoteOpenDeviceList`)]}),i?.settings.enabled?(0,P.jsx)(v,{variant:`outline`,onClick:()=>void e.remoteAccessManager.disableRemoteAccess(i),disabled:u,children:t(`remoteDisable`)}):null]}),l.shouldShowIssueHint&&_?(0,P.jsx)(D,{tone:`warning`,title:_.title,description:_.body}):null,(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`remoteOpenWebHint`)})]})]}),(0,P.jsxs)(p,{children:[(0,P.jsxs)(m,{children:[(0,P.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,P.jsx)(k,{className:`h-4 w-4 text-primary`}),t(`remoteDeviceSectionTitle`)]}),(0,P.jsx)(C,{children:t(`remoteDeviceSectionDescription`)})]}),(0,P.jsxs)(o,{className:`space-y-5`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(O,{status:i?.account.loggedIn?`ready`:`inactive`,label:i?.account.loggedIn?t(`remoteAccountConnected`):t(`remoteAccountNotConnected`)}),(0,P.jsx)(O,{status:i?.settings.enabled?`active`:`inactive`,label:i?.settings.enabled?t(`remoteEnabled`):t(`remoteStateDisabled`)}),(0,P.jsx)(O,{status:i?.service.running?`active`:`inactive`,label:i?.service.running?t(`remoteServiceRunning`):t(`remoteServiceStopped`)})]}),(0,P.jsxs)(D,{tone:`neutral`,children:[(0,P.jsx)(F,{label:t(`remoteDeviceName`),value:d}),(0,P.jsx)(F,{label:t(`remoteConnectionStatus`),value:g.badgeLabel}),(0,P.jsx)(F,{label:t(`remoteLastConnectedAt`),value:i?.runtime?.lastConnectedAt?r(i.runtime.lastConnectedAt):`-`,muted:!0})]}),(0,P.jsx)(D,{tone:`neutral`,borderStyle:`dashed`,description:i?.account.loggedIn?t(`remoteOpenWebHint`):t(`remoteStatusNeedsSignInDescription`),className:`text-sm`})]})]})]})]})}var I=[`remote-status`],L=`https://platform.nextclaw.io`,R=`https://nextclaw-platform-console.pages.dev`,z=async()=>await d.fetchQuery({queryKey:I,queryFn:h,staleTime:5e3}),B=async()=>(await d.invalidateQueries({queryKey:I}),await z()),V=(e,t)=>t?.trim()||e?.settings.platformApiBase?.trim()||e?.account.apiBase?.trim()||void 0;function H(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 L;if(n.hostname.includes(`nextclaw-provider-gateway-api`)&&n.hostname.endsWith(`.workers.dev`))return R}var U=e=>H(e?.account.apiBase)||H(e?.settings.platformApiBase)||H(e?.platformBase)||H(e?.account.platformBase)||void 0,W=g(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})})),G=class{constructor(){this.accountManager=null,this.bindAccountManager=e=>{this.accountManager=e},this.syncStatus=e=>{if(!e)return;let t=W.getState();t.draftTouched||t.actionLabel||this.hydrateDraftFromStatus(e)},this.setEnabled=e=>{W.getState().setEnabled(e)},this.setDeviceName=e=>{W.getState().setDeviceName(e)},this.setPlatformApiBase=e=>{W.getState().setPlatformApiBase(e)},this.setAdvancedOpen=e=>{W.getState().setAdvancedOpen(e)},this.enableRemoteAccess=async e=>{let t=e??await B(),n=W.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 B();await this.applyEnabledState(!1,t)},this.repairRemoteAccess=async e=>{let n=e??await B();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 B();this.hydrateDraftFromStatus(e)},successMessage:t(`remoteServiceRecovered`)})},this.reauthorizeRemoteAccess=async e=>{let t=e??await B();await this.accountManager?.startBrowserSignIn({status:t,apiBase:W.getState().platformApiBase,pendingAction:{type:`repair-remote`}})},this.saveAdvancedSettings=async e=>{let n=e??await B(),r=W.getState();await this.runManagedAction({actionLabel:t(`remoteActionSavingAdvanced`),job:async()=>{await x({enabled:r.enabled,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let e=await B();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 ee();W.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=W.getState();await this.runManagedAction({actionLabel:t(e?`remoteActionEnabling`:`remoteActionDisabling`),job:async()=>{await x({enabled:e,deviceName:r.deviceName.trim(),platformApiBase:r.platformApiBase.trim()});let t=await B();this.hydrateDraftFromStatus(t),e?await b(t.service.running?`restart`:`start`):n.service.running&&await b(`restart`);let i=await B();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 B();this.hydrateDraftFromStatus(n),l.success(t.message)}})},this.hydrateDraftFromStatus=e=>{W.getState().hydrateDraft({enabled:e.settings.enabled,deviceName:e.settings.deviceName,platformApiBase:e.settings.platformApiBase})},this.runManagedAction=async e=>{W.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{W.getState().finishAction()}}}},ue=[/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 K(e){return e?.runtime?.lastError?.trim()||``}function de(e){let n=t(`remoteStatusIssueDetailGeneric`),r=K(e);return r?`${n} (${r})`:n}function q(e){if(!e?.settings.enabled)return!1;let t=K(e);return ue.some(e=>e.test(t))}function J(e){return q(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:de(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 Y=g(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 X({label:e,value:t}){return(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-2 text-sm`,children:[(0,P.jsx)(`span`,{className:`text-gray-500`,children:e}),(0,P.jsx)(`span`,{className:`text-right text-gray-900`,children:t?.trim()||`-`})]})}function fe(e){let{email:n,username:r,role:i,canSubmitUsername:o,savingUsername:s,usernameDraft:c,onUsernameDraftChange:l,onSubmitUsername:u,onOpenDeviceList:d,onLogout:f}=e;return(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsx)(D,{tone:`success`,title:t(`accountPanelSignedInTitle`),description:t(`accountPanelSignedInDescription`)}),(0,P.jsxs)(D,{tone:`neutral`,children:[(0,P.jsx)(X,{label:t(`remoteAccountEmail`),value:n}),(0,P.jsx)(X,{label:t(`remoteAccountUsername`),value:r}),(0,P.jsx)(X,{label:t(`remoteAccountRole`),value:i})]}),r?(0,P.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`remoteAccountUsernameLockedHelp`)}):(0,P.jsxs)(D,{tone:`warning`,title:t(`remoteAccountUsernameRequiredTitle`),description:t(`remoteAccountUsernameRequiredDescription`),children:[(0,P.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,P.jsx)(te,{htmlFor:`account-panel-username`,children:t(`remoteAccountUsername`)}),(0,P.jsx)(a,{id:`account-panel-username`,value:c,onChange:e=>l(e.target.value),placeholder:t(`remoteAccountUsernamePlaceholder`),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1})]}),(0,P.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-3`,children:(0,P.jsx)(v,{disabled:!o,onClick:()=>void u(),children:t(s?`remoteAccountUsernameSaving`:`remoteAccountUsernameSave`)})})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,P.jsxs)(v,{onClick:()=>void d(),children:[(0,P.jsx)(j,{className:`mr-2 h-4 w-4`}),t(`remoteOpenDeviceList`)]}),(0,P.jsxs)(v,{variant:`outline`,onClick:()=>void f(),children:[(0,P.jsx)(A,{className:`mr-2 h-4 w-4`}),t(`remoteLogout`)]})]})]})}function pe(e){let{authSessionId:n,authExpiresAt:i,authStatusMessage:a,authVerificationUri:o,onStartBrowserSignIn:s,onResumeBrowserSignIn:c}=e;return(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsx)(D,{tone:`neutral`,title:t(`accountPanelSignedOutTitle`),description:t(`accountPanelSignedOutDescription`),children:n?(0,P.jsxs)(`div`,{className:`mt-3 border-t border-white/80 pt-3`,children:[(0,P.jsx)(X,{label:t(`remoteBrowserAuthSession`),value:n}),(0,P.jsx)(X,{label:t(`remoteBrowserAuthExpiresAt`),value:i?r(i):`-`})]}):null}),a?(0,P.jsx)(`p`,{className:`text-sm text-gray-600`,children:a}):null,(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,P.jsx)(v,{onClick:()=>void s(),children:t(n?`remoteBrowserAuthActionRetry`:`remoteBrowserAuthAction`)}),o?(0,P.jsx)(v,{variant:`outline`,onClick:c,children:t(`remoteBrowserAuthResume`)}):null]})]})}function me(){let e=$(),n=M(),r=Y(e=>e.panelOpen),i=Y(e=>e.authSessionId),a=Y(e=>e.authVerificationUri),o=Y(e=>e.authExpiresAt),s=Y(e=>e.authStatusMessage),c=n.data,[l,u]=(0,N.useState)(``),[d,f]=(0,N.useState)(!1);(0,N.useEffect)(()=>{e.accountManager.syncRemoteStatus(c)},[e,c]);let p=!d&&l.trim().length>0&&!c?.account.username;return(0,P.jsx)(T,{open:r,onOpenChange:t=>t?e.accountManager.openAccountPanel():e.accountManager.closeAccountPanel(),children:(0,P.jsxs)(ie,{className:`max-w-xl`,children:[(0,P.jsxs)(w,{children:[(0,P.jsxs)(ae,{className:`flex items-center gap-2`,children:[(0,P.jsx)(se,{className:`h-5 w-5 text-primary`}),t(`accountPanelTitle`)]}),(0,P.jsx)(oe,{children:t(`accountPanelDescription`)})]}),c?.account.loggedIn?(0,P.jsx)(fe,{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,P.jsx)(pe,{authSessionId:i,authExpiresAt:o,authStatusMessage:s,authVerificationUri:a,onStartBrowserSignIn:()=>e.accountManager.startBrowserSignIn(),onResumeBrowserSignIn:()=>e.accountManager.resumeBrowserSignIn()})]})})}function he({username:e}){let n=S(),[r,i]=(0,N.useState)(e??``),[s,l]=(0,N.useState)(``),u=r.trim().length>0&&s.length>0&&!n.isPending;return(0,P.jsx)(`main`,{className:`flex min-h-screen items-center justify-center bg-secondary px-6 py-10`,children:(0,P.jsxs)(p,{hover:!1,className:`w-full max-w-md shadow-card-hover`,children:[(0,P.jsxs)(m,{children:[(0,P.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-[0.24em] text-gray-500`,children:t(`authBrand`)}),(0,P.jsx)(c,{className:`text-2xl`,children:t(`authLoginTitle`)}),(0,P.jsx)(C,{children:t(`authLoginDescription`)})]}),(0,P.jsx)(o,{children:(0,P.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e?.preventDefault(),u&&n.mutate({username:r.trim(),password:s})},children:[(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:t(`authUsername`)}),(0,P.jsx)(a,{value:r,onChange:e=>i(e.target.value),placeholder:t(`authUsernamePlaceholder`),autoFocus:!0})]}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`label`,{className:`text-sm font-medium text-gray-800`,children:t(`authPassword`)}),(0,P.jsx)(a,{type:`password`,value:s,onChange:e=>l(e.target.value),placeholder:t(`authPasswordPlaceholder`)})]}),(0,P.jsx)(v,{type:`submit`,className:`w-full`,disabled:!u,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=()=>{Y.getState().openPanel()},this.closeAccountPanel=()=>{Y.getState().closePanel()},this.syncRemoteStatus=e=>{e?.account.loggedIn&&(this.clearPollTimer(),Y.getState().clearBrowserAuth())},this.ensureSignedIn=async e=>{let t=await z();return t.account.loggedIn?!0:(e?.pendingAction&&Y.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 z();r&&Y.getState().setPendingAction(r);let a=await _({apiBase:V(i,n)});Y.getState().beginBrowserAuth({sessionId:a.sessionId,verificationUri:a.verificationUri,expiresAt:a.expiresAt,intervalMs:a.intervalMs,statusMessage:t(`remoteBrowserAuthWaiting`)}),window.open(a.verificationUri,`_blank`,`noopener,noreferrer`)||Y.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=Y.getState().authVerificationUri;e&&window.open(e,`_blank`,`noopener,noreferrer`)},this.logout=async()=>{try{await ne(),Y.getState().clearPendingAction(),Y.getState().clearBrowserAuth(),await B(),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 y({username:e.trim()}),await B(),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=U(await z());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}=Y.getState();e&&(this.authPollTimerId=window.setTimeout(async()=>{await this.pollBrowserSignIn()},t))},this.pollBrowserSignIn=async()=>{let e=Y.getState();if(e.authSessionId)try{let n=await z(),r=await re({sessionId:e.authSessionId,apiBase:V(n)});if(r.status===`pending`){Y.getState().updateBrowserAuth({statusMessage:t(`remoteBrowserAuthWaiting`),intervalMs:r.nextPollMs??1500}),this.scheduleBrowserAuthPoll();return}if(r.status===`expired`){this.clearPollTimer(),Y.getState().clearBrowserAuth(),l.error(r.message||t(`remoteBrowserAuthExpired`));return}Y.getState().setAuthStatusMessage(t(`remoteBrowserAuthCompleted`));let i=await B(),{pendingAction:a}=Y.getState();this.clearPollTimer(),Y.getState().clearBrowserAuth(),l.success(t(`remoteLoginSuccess`)),a&&this.afterSignedIn&&await this.afterSignedIn(a,i),Y.getState().clearPendingAction()}catch(e){this.clearPollTimer(),Y.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=Y.getState();return{sessionId:e.authSessionId,expiresAt:e.authExpiresAt?r(e.authExpiresAt):`-`}}}},Z=new class{constructor(){this.accountManager=new ge,this.remoteAccessManager=new G}};Z.accountManager.bindSignedInContinuation(Z.remoteAccessManager.resumePendingActionAfterSignIn),Z.remoteAccessManager.bindAccountManager(Z.accountManager);var Q=(0,N.createContext)(null);function _e({children:e}){return(0,P.jsx)(Q.Provider,{value:Z,children:e})}function $(){let e=(0,N.useContext)(Q);if(!e)throw Error(`useAppManager must be used inside AppManagerProvider`);return e}export{J as a,W as c,B as d,V as f,M as h,me as i,I as l,le as m,$ as n,q as o,U as p,he as r,G as s,_e as t,z as u};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{_ as e,h as t,i as n,m as r,n as i,o as a,p as o,u as s}from"./i18n-C5Mibli1.js";import{At as c,Bt as l,Dt as u,Ft as d,It as f,Lt as p,Ot as m,dt as h,et as g,jt as _,kt as v,ot as y,tt as b}from"./api-BcqDx0tm.js";import{t as x}from"./createLucideIcon-BZkY6emz.js";import{t as S}from"./search-vChioOoe.js";import{t as C}from"./book-open-DgLqYpNY.js";import{O as ee,a as te,i as ne,n as re,r as ie,t as ae}from"./select-DIZrwsKU.js";import{t as w}from"./external-link-Sw3ah_JD.js";import{n as oe,t as T}from"./logos-CqVm0q0W.js";import{t as se}from"./hash-zajSTDXZ.js";import{t as ce}from"./key-round-CnI1mc9F.js";import{t as E}from"./loader-circle-B5i8oMMY.js";import{t as le}from"./message-square-D6Z4NwpG.js";import{t as ue}from"./settings-CiRChctQ.js";import{t as de}from"./x-DpTzXQcX.js";import{t as D}from"./status-dot-Dv_hiUVa.js";import{t as fe}from"./use-viewport-layout-BX3XqzJ4.js";import{b as pe,i as O,n as k,r as A,u as me}from"./use-config-BQJjq1mP.js";import{t as j}from"./logo-badge-BQgKnVtz.js";import{t as he}from"./tabs-custom-CsACkVji.js";import{t as ge}from"./tag-chip-C3wDBe_-.js";import{t as M}from"./config-hints-MogHYQ8G.js";import{a as N,c as P,i as _e,n as ve,o as F,r as ye,s as be,t as xe}from"./config-split-page-BMRGuCJQ.js";var Se=x(`Mail`,[[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}],[`path`,{d:`m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7`,key:`1ocrg3`}]]),Ce=x(`MessageCircleMore`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),I=x(`QrCode`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),we=x(`ToggleLeft`,[[`rect`,{width:`20`,height:`12`,x:`2`,y:`6`,rx:`6`,ry:`6`,key:`f2vt7d`}],[`circle`,{cx:`8`,cy:`12`,r:`2`,key:`1nvbw3`}]]),L=e(r(),1),R=o();function Te({value:e,onChange:t,className:r,placeholder:i=``}){let[a,o]=(0,L.useState)(``),c=n=>{n.key===`Enter`&&a.trim()?(n.preventDefault(),t([...e,a.trim()]),o(``)):n.key===`Backspace`&&!a&&e.length>0&&t(e.slice(0,-1))},l=n=>{t(e.filter((e,t)=>t!==n))};return(0,R.jsxs)(`div`,{className:s(`flex min-h-[42px] flex-wrap gap-2 rounded-xl border border-gray-200/80 bg-white p-2`,r),children:[e.map((e,t)=>(0,R.jsxs)(ge,{tone:`info`,className:`gap-1 px-2 py-1 text-sm`,children:[e,(0,R.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:`transition-colors hover:text-rose-200`,children:(0,R.jsx)(de,{className:`h-3 w-3`})})]},t)),(0,R.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),onKeyDown:c,className:`flex-1 outline-none min-w-[100px] bg-transparent text-sm`,placeholder:i||n(`enterTag`)})]})}function Ee(e){return e.includes(`token`)||e.includes(`secret`)||e.includes(`password`)?(0,R.jsx)(ce,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`url`)||e.includes(`host`)?(0,R.jsx)(oe,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`email`)||e.includes(`mail`)?(0,R.jsx)(Se,{className:`h-3.5 w-3.5 text-gray-500`}):e.includes(`id`)||e.includes(`from`)?(0,R.jsx)(se,{className:`h-3.5 w-3.5 text-gray-500`}):e===`enabled`||e===`consentGranted`?(0,R.jsx)(we,{className:`h-3.5 w-3.5 text-gray-500`}):(0,R.jsx)(ue,{className:`h-3.5 w-3.5 text-gray-500`})}function De({channelName:e,fields:t,formData:r,jsonDrafts:i,setJsonDrafts:a,updateField:o,uiHints:s}){return(0,R.jsx)(R.Fragment,{children:t.map(t=>{let l=M(`channels.${e}.${t.name}`,s),u=l?.label??t.label,d=l?.placeholder;return(0,R.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,R.jsxs)(v,{htmlFor:t.name,className:`flex items-center gap-2 text-sm font-medium text-gray-900`,children:[Ee(t.name),u]}),t.type===`boolean`&&(0,R.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl bg-gray-50 p-3`,children:[(0,R.jsx)(`span`,{className:`text-sm text-gray-500`,children:r[t.name]?n(`enabled`):n(`disabled`)}),(0,R.jsx)(h,{id:t.name,checked:r[t.name]||!1,onCheckedChange:e=>o(t.name,e),className:`data-[state=checked]:bg-emerald-500`})]}),(t.type===`text`||t.type===`email`)&&(0,R.jsx)(c,{id:t.name,type:t.type,value:r[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:d,className:`rounded-xl`}),t.type===`password`&&(0,R.jsx)(c,{id:t.name,type:`password`,value:r[t.name]||``,onChange:e=>o(t.name,e.target.value),placeholder:d??n(`leaveBlankToKeepUnchanged`),className:`rounded-xl`}),t.type===`number`&&(0,R.jsx)(c,{id:t.name,type:`number`,value:r[t.name]||0,onChange:e=>o(t.name,parseInt(e.target.value,10)||0),placeholder:d,className:`rounded-xl`}),t.type===`tags`&&(0,R.jsx)(Te,{value:r[t.name]||[],onChange:e=>o(t.name,e)}),t.type===`select`&&(0,R.jsxs)(ae,{value:r[t.name]||``,onValueChange:e=>o(t.name,e),children:[(0,R.jsx)(ne,{className:`rounded-xl`,children:(0,R.jsx)(te,{})}),(0,R.jsx)(re,{children:(t.options??[]).map(e=>(0,R.jsx)(ie,{value:e.value,children:e.label},e.value))})]}),t.type===`json`&&(0,R.jsx)(`textarea`,{id:t.name,value:i[t.name]??`{}`,onChange:e=>a(n=>({...n,[t.name]:e.target.value})),className:`min-h-[120px] w-full resize-none rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs font-mono`})]},t.name)})})}var Oe=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),z=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),B=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),ke=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ae=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),je=t((e=>{var t=z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Me=t((e=>{var t=z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),Ne=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),V=t((e=>{var t=B(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),Pe=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Fe=t((e=>{var t=Pe();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),Ie=t(((e,t)=>{var n=Fe();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),H=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),U=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
2
|
-
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),W=t((e=>{var t=H(),n=U();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),Le=t((e=>{var t=z(),n=V(),r=B(),i=W(),a=H(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),Re=t((e=>{var t=z(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),ze=t(((e,t)=>{var n=W();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Be=t(((e,t)=>{var n=W(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),Ve=t(((e,t)=>{var n=W();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),He=t(((e,t)=>{var n=W(),r=z();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
3
|
-
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),Ue=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),We=t((e=>{var t=W(),n=ze(),r=Be(),i=Ve(),a=He(),o=U(),s=z(),c=Ue();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
4
|
-
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),Ge=t((e=>{var t=z(),n=B(),r=ke(),i=Ae(),a=je(),o=Me(),s=Ne(),c=V(),l=Ie(),u=Le(),d=Re(),f=W(),p=We();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
|
5
|
-
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
-
Minimum version required to store current data is: `+c+`.
|
|
7
|
-
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),G=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[a[t*i+r]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),Ke=t((e=>{var t=G();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),qe=t((e=>{var t=G();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
8
|
-
`;return typeof a==`function`&&a(null,p),p}})),Je=t((e=>{var t=Oe(),n=Ge(),r=Ke(),i=qe();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))();function Ye(){return f({mutationFn:({channel:e,data:t})=>b(e,t)})}function Xe(){return f({mutationFn:({channel:e,data:t})=>g(e,t)})}function Ze(e){let{accounts:t}=e,n=new Set;if(typeof e.defaultAccountId==`string`&&e.defaultAccountId.trim()&&n.add(e.defaultAccountId.trim()),t&&typeof t==`object`&&!Array.isArray(t))for(let e of Object.keys(t)){let t=e.trim();t&&n.add(t)}return[...n]}function Qe(e,t){if(typeof e.baseUrl==`string`&&e.baseUrl.trim())return e.baseUrl.trim();if(typeof t.baseUrl==`string`&&t.baseUrl.trim())return t.baseUrl.trim()}function $e(e){return p({queryKey:[`weixin-channel-qr`,e],enabled:!!e,queryFn:()=>(0,Je.toDataURL)(e,{errorCorrectionLevel:`M`,margin:1,width:480})}).data??null}function et(e){return(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsxs)(`div`,{className:`inline-flex items-center gap-2 rounded-full bg-white/90 px-3 py-1 text-xs font-medium text-primary shadow-sm`,children:[(0,R.jsx)(I,{className:`h-3.5 w-3.5`}),n(`weixinAuthTitle`)]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`text-base font-semibold text-gray-900`,children:n(`weixinAuthDescription`)}),(0,R.jsx)(`p`,{className:`mt-1 text-sm text-gray-600`,children:n(`weixinAuthHint`)})]}),(0,R.jsxs)(`div`,{className:s(`inline-flex w-fit items-center gap-2 rounded-full px-3 py-1 text-xs font-medium`,e.activeSession?`bg-amber-50 text-amber-700`:e.hasConnectedAccount?`bg-emerald-50 text-emerald-700`:`bg-gray-100 text-gray-600`),children:[e.activeSession?(0,R.jsx)(E,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(Ce,{className:`h-3.5 w-3.5`}),e.statusLabel]}),(0,R.jsxs)(`div`,{className:`space-y-1 text-sm text-gray-600`,children:[(0,R.jsx)(`p`,{children:e.channelEnabled||!e.hasConnectedAccount?n(`weixinAuthCapabilityHint`):n(`weixinAuthDisabledHint`)}),e.primaryAccountId?(0,R.jsxs)(`p`,{children:[n(`weixinAuthPrimaryAccount`),`: `,(0,R.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:e.primaryAccountId})]}):null,e.connectedAccountIds.length>1?(0,R.jsxs)(`p`,{children:[n(`weixinAuthConnectedAccounts`),`: `,(0,R.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:e.connectedAccountIds.join(`, `)})]}):null,e.baseUrl?(0,R.jsxs)(`p`,{children:[n(`weixinAuthBaseUrl`),`: `,(0,R.jsx)(`span`,{className:`font-mono text-xs text-gray-900`,children:e.baseUrl})]}):null]}),(0,R.jsx)(_,{type:`button`,onClick:()=>void e.handleStartAuth(),disabled:e.disabled,className:`rounded-xl`,children:e.connectButtonLabel})]})}function tt(e){return(0,R.jsx)(`div`,{className:`w-full max-w-sm rounded-2xl border border-dashed border-primary/25 bg-white/85 p-4 shadow-sm`,children:e.activeSession?(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-gray-100 bg-white p-3`,children:e.qrDataUrl?(0,R.jsx)(`img`,{src:e.qrDataUrl,alt:n(`weixinAuthQrAlt`),className:`mx-auto aspect-square w-full max-w-[240px] object-contain`}):(0,R.jsx)(`div`,{className:`flex aspect-square w-full items-center justify-center rounded-xl bg-gray-50 text-gray-500`,children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center`,children:[(0,R.jsx)(E,{className:`h-5 w-5 animate-spin`}),(0,R.jsx)(`p`,{className:`text-xs`,children:n(`weixinAuthStarting`)})]})})}),(0,R.jsxs)(`div`,{className:`space-y-1 text-xs text-gray-500`,children:[(0,R.jsx)(`p`,{children:e.authMessage||e.activeSession.note||n(`weixinAuthScanPrompt`)}),(0,R.jsxs)(`p`,{children:[n(`weixinAuthExpiresAt`),`: `,i(e.activeSession.expiresAt)]})]}),(0,R.jsxs)(`a`,{href:e.activeSession.qrCodeUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,R.jsx)(w,{className:`h-3.5 w-3.5`}),n(`weixinAuthOpenQr`)]})]}):(0,R.jsxs)(`div`,{className:`flex min-h-[280px] flex-col items-center justify-center rounded-2xl bg-gray-50/80 px-6 text-center`,children:[(0,R.jsx)(I,{className:`h-9 w-9 text-gray-300`}),(0,R.jsx)(`p`,{className:`mt-3 text-sm font-medium text-gray-700`,children:n(`weixinAuthReadyTitle`)}),(0,R.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-gray-500`,children:n(`weixinAuthReadyDescription`)})]})})}function nt(e){let t=l(),r=Ye(),i=Xe(),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(null),[u,f]=(0,L.useState)(!1),p=(0,L.useMemo)(()=>Ze(e.channelConfig),[e.channelConfig]),m=p[0],h=Qe(e.formData,e.channelConfig),g=p.length>0,_=g&&!u?null:a,v=$e(_?.qrCodeUrl);(0,L.useEffect)(()=>{if(!_)return;let e=!1,r=null,a=async()=>{try{let s=await i.mutateAsync({channel:`weixin`,data:{sessionId:_.sessionId}});if(e)return;if(c(s),s.status===`authorized`){await t.invalidateQueries({queryKey:[`config`]}),await t.invalidateQueries({queryKey:[`config-meta`]}),d.success(s.message||n(`weixinAuthAuthorized`)),o(null);return}if(s.status===`expired`||s.status===`error`){d.error(s.message||n(`weixinAuthRetryRequired`)),o(null);return}r=setTimeout(a,s.nextPollMs??_.intervalMs)}catch(t){e||(d.error(`${n(`error`)}: ${t instanceof Error?t.message:String(t)}`),o(null))}};return r=setTimeout(a,_.intervalMs),()=>{e=!0,r&&clearTimeout(r)}},[_,i,t]);let y=async()=>{try{let t=await r.mutateAsync({channel:`weixin`,data:{baseUrl:h,accountId:typeof e.formData.defaultAccountId==`string`&&e.formData.defaultAccountId.trim()?e.formData.defaultAccountId.trim():void 0}});f(g),o(t),c({channel:`weixin`,status:`pending`,message:t.note,nextPollMs:t.intervalMs})}catch(e){d.error(`${n(`error`)}: ${e instanceof Error?e.message:String(e)}`)}},b=_?s?.status===`scanned`?n(`weixinAuthScanned`):n(`weixinAuthWaiting`):g?e.channelEnabled?n(`weixinAuthAuthorized`):n(`weixinAuthConnectedDisabled`):n(`weixinAuthNotConnected`),x=r.isPending?n(`weixinAuthStarting`):n(_?`weixinAuthWaiting`:g?`weixinAuthReconnect`:`weixinAuthConnect`),S=g?n(`weixinAuthAuthorized`):s?.message;return(0,R.jsx)(`section`,{className:`rounded-2xl border border-primary/20 bg-gradient-to-br from-primary-50/70 via-white to-emerald-50/60 p-5`,children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:[(0,R.jsx)(et,{activeSession:_,baseUrl:h,channelEnabled:e.channelEnabled,connectButtonLabel:x,connectedAccountIds:p,disabled:e.disabled||r.isPending||!!_,handleStartAuth:y,hasConnectedAccount:g,primaryAccountId:m,statusLabel:b}),(0,R.jsx)(tt,{activeSession:_,authMessage:S,qrDataUrl:v})]})})}var K=[{value:`pairing`,label:`pairing`},{value:`allowlist`,label:`allowlist`},{value:`open`,label:`open`},{value:`disabled`,label:`disabled`}],q=[{value:`open`,label:`open`},{value:`allowlist`,label:`allowlist`},{value:`disabled`,label:`disabled`}],rt=[{value:`off`,label:`off`},{value:`partial`,label:`partial`},{value:`block`,label:`block`},{value:`progress`,label:`progress`}];function it(){return{telegram:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`token`,type:`password`,label:n(`botToken`)},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)},{name:`proxy`,type:`text`,label:n(`proxy`)},{name:`accountId`,type:`text`,label:n(`accountId`)},{name:`dmPolicy`,type:`select`,label:n(`dmPolicy`),options:K},{name:`groupPolicy`,type:`select`,label:n(`groupPolicy`),options:q},{name:`groupAllowFrom`,type:`tags`,label:n(`groupAllowFrom`)},{name:`requireMention`,type:`boolean`,label:n(`requireMention`)},{name:`mentionPatterns`,type:`tags`,label:n(`mentionPatterns`)},{name:`groups`,type:`json`,label:n(`groupRulesJson`)}]},discord:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`token`,type:`password`,label:n(`botToken`)},{name:`allowBots`,type:`boolean`,label:n(`allowBotMessages`)},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)},{name:`gatewayUrl`,type:`text`,label:n(`gatewayUrl`)},{name:`intents`,type:`number`,label:n(`intents`)},{name:`proxy`,type:`text`,label:n(`proxy`)},{name:`mediaMaxMb`,type:`number`,label:n(`attachmentMaxSizeMb`)},{name:`streaming`,type:`select`,label:n(`streamingMode`),options:rt},{name:`draftChunk`,type:`json`,label:n(`draftChunkingJson`)},{name:`textChunkLimit`,type:`number`,label:n(`textChunkLimit`)},{name:`accountId`,type:`text`,label:n(`accountId`)},{name:`dmPolicy`,type:`select`,label:n(`dmPolicy`),options:K},{name:`groupPolicy`,type:`select`,label:n(`groupPolicy`),options:q},{name:`groupAllowFrom`,type:`tags`,label:n(`groupAllowFrom`)},{name:`requireMention`,type:`boolean`,label:n(`requireMention`)},{name:`mentionPatterns`,type:`tags`,label:n(`mentionPatterns`)},{name:`groups`,type:`json`,label:n(`groupRulesJson`)}]},whatsapp:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`bridgeUrl`,type:`text`,label:n(`bridgeUrl`)},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)}]},feishu:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`appId`,type:`text`,label:n(`appId`)},{name:`appSecret`,type:`password`,label:n(`appSecret`)},{name:`encryptKey`,type:`password`,label:n(`encryptKey`)},{name:`verificationToken`,type:`password`,label:n(`verificationToken`)},{name:`domain`,type:`text`,label:`Domain`},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)},{name:`dmPolicy`,type:`select`,label:n(`dmPolicy`),options:K},{name:`groupPolicy`,type:`select`,label:n(`groupPolicy`),options:q},{name:`groupAllowFrom`,type:`tags`,label:n(`groupAllowFrom`)},{name:`requireMention`,type:`boolean`,label:n(`requireMention`)},{name:`mentionPatterns`,type:`tags`,label:n(`mentionPatterns`)},{name:`groups`,type:`json`,label:n(`groupRulesJson`)},{name:`accounts`,type:`json`,label:n(`accountsJson`)}]},dingtalk:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`clientId`,type:`text`,label:n(`clientId`)},{name:`clientSecret`,type:`password`,label:n(`clientSecret`)},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)}]},wecom:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`corpId`,type:`text`,label:n(`corpId`)},{name:`agentId`,type:`text`,label:n(`agentId`)},{name:`secret`,type:`password`,label:n(`secret`)},{name:`token`,type:`password`,label:n(`token`)},{name:`callbackPort`,type:`number`,label:n(`callbackPort`)},{name:`callbackPath`,type:`text`,label:n(`callbackPath`)},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)}]},weixin:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`),section:`primary`},{name:`defaultAccountId`,type:`text`,label:n(`defaultAccountId`)},{name:`baseUrl`,type:`text`,label:n(`baseUrl`)},{name:`pollTimeoutMs`,type:`number`,label:n(`pollTimeoutMs`)},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)},{name:`accounts`,type:`json`,label:n(`accountsJson`)}],layout:[{type:`fields`,section:`primary`},{type:`custom`,sectionId:`weixin-auth`},{type:`fields`,section:`advanced`,collapsible:{title:n(`weixinAuthAdvancedTitle`),description:n(`weixinAuthAdvancedDescription`)}}]},slack:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`mode`,type:`text`,label:n(`mode`)},{name:`webhookPath`,type:`text`,label:n(`webhookPath`)},{name:`allowBots`,type:`boolean`,label:n(`allowBotMessages`)},{name:`botToken`,type:`password`,label:n(`botToken`)},{name:`appToken`,type:`password`,label:n(`appToken`)}]},email:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`consentGranted`,type:`boolean`,label:n(`consentGranted`)},{name:`imapHost`,type:`text`,label:n(`imapHost`)},{name:`imapPort`,type:`number`,label:n(`imapPort`)},{name:`imapUsername`,type:`text`,label:n(`imapUsername`)},{name:`imapPassword`,type:`password`,label:n(`imapPassword`)},{name:`fromAddress`,type:`email`,label:n(`fromAddress`)}]},mochat:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`baseUrl`,type:`text`,label:n(`baseUrl`)},{name:`clawToken`,type:`password`,label:n(`clawToken`)},{name:`agentUserId`,type:`text`,label:n(`agentUserId`)},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)}]},qq:{fields:[{name:`enabled`,type:`boolean`,label:n(`enabled`)},{name:`appId`,type:`text`,label:n(`appId`)},{name:`secret`,type:`password`,label:n(`appSecret`)},{name:`markdownSupport`,type:`boolean`,label:n(`markdownSupport`)},{name:`allowFrom`,type:`tags`,label:n(`allowFrom`)}]}}}function J(e){let t=a();return e.tutorialUrls?.[t]||e.tutorialUrls?.default||e.tutorialUrl}var at=[],ot=[{type:`fields`,section:`all`}],Y=new Set,X=new Map,Z=null;function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $(e,t){let n={...e};for(let[e,r]of Object.entries(t))n[e]=Q(n[e])&&Q(r)?$(n[e],r):r;return n}function st(e,t){let n={},r=n,i=e.split(`.`);for(let e=0;e<i.length-1;e+=1)r[i[e]]={},r=r[i[e]];return r[i[i.length-1]]=t,n}function ct(e,t){return t===`all`?e:e.filter(e=>t===`primary`?e.section===`primary`:e.section!==`primary`)}function lt(e,t){let n={};return t.filter(e=>e.type===`json`).forEach(t=>{n[t.name]=JSON.stringify(e[t.name]??{},null,2)}),n}function ut(){Z||=y.realtime.subscribe(e=>{e.type===`channel.config.apply-status`&&(X.set(e.payload.channel,e.payload.status===`started`?{status:`applying`}:e.payload.status===`succeeded`?{status:`applied`}:{status:`failed`,message:e.payload.message}),Y.forEach(e=>e()))}).close}function dt(e){return Y.add(e),ut(),()=>{Y.delete(e),!Y.size&&Z&&(Z(),Z=null,X.clear())}}function ft(e){return(0,L.useSyncExternalStore)(dt,()=>e?X.get(e)??null:null,()=>null)}function pt(e){return e?e.status===`applying`?{className:`text-amber-600`,label:n(`channelConfigApplying`)}:e.status===`applied`?{className:`text-emerald-600`,label:n(`channelConfigApplied`)}:{className:`text-red-600`,label:`${n(`channelConfigApplyFailed`)}${e.message?`: ${e.message}`:``}`}:null}function mt(e){return(0,R.jsx)(P,{className:`px-6 py-5`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(j,{name:e.channelName,src:T(e.channelName),className:s(`h-9 w-9 rounded-lg border`,e.enabled?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,R.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:e.channelName[0]})}),(0,R.jsx)(`h3`,{className:`truncate text-lg font-semibold text-gray-900 capitalize`,children:e.channelLabel})]}),(0,R.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:n(`channelsFormDescription`)}),e.channelApplyStatus?(0,R.jsx)(`p`,{className:s(`mt-2 text-xs font-medium`,e.channelApplyStatus.className),children:e.channelApplyStatus.label}):null,e.tutorialUrl?(0,R.jsxs)(`a`,{href:e.tutorialUrl,className:`mt-2 inline-flex items-center gap-1.5 text-xs text-primary transition-colors hover:text-primary-hover`,children:[(0,R.jsx)(C,{className:`h-3.5 w-3.5`}),n(`channelsGuideTitle`)]}):null]}),(0,R.jsx)(D,{status:e.enabled?`active`:`inactive`,label:e.enabled?n(`statusActive`):n(`statusInactive`)})]})})}function ht(e){return(0,R.jsx)(R.Fragment,{children:e.layoutBlocks.map((t,n)=>{if(t.type===`fields`){let r=ct(e.fields,t.section);if(r.length===0)return null;let i=(0,R.jsx)(De,{channelName:e.channelName,fields:r,formData:e.formData,jsonDrafts:e.jsonDrafts,setJsonDrafts:e.setJsonDrafts,updateField:e.updateField,uiHints:e.uiHints});return t.collapsible?(0,R.jsxs)(`details`,{className:`group rounded-2xl border border-gray-200/80 bg-white`,children:[(0,R.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 px-5 py-4 text-sm font-medium text-gray-900`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{children:t.collapsible.title}),t.collapsible.description?(0,R.jsx)(`p`,{className:`mt-1 text-xs font-normal text-gray-500`,children:t.collapsible.description}):null]}),(0,R.jsx)(ee,{className:`h-4 w-4 text-gray-400 transition-transform group-open:rotate-180`})]}),(0,R.jsx)(`div`,{className:`space-y-6 border-t border-gray-100 px-5 py-5`,children:i})]},`${t.type}-${t.section}-${n}`):(0,R.jsx)(`div`,{children:i},`${t.type}-${t.section}-${n}`)}return t.sectionId===`weixin-auth`?(0,R.jsx)(nt,{channelConfig:e.channelConfig,formData:e.formData,channelEnabled:e.enabled,disabled:e.disabled},`${t.type}-${t.sectionId}-${n}`):null})})}function gt(e){let t=pe(),r=me(),[i,a]=(0,L.useState)(()=>({...e.channelConfig})),[o,s]=(0,L.useState)(()=>lt(e.channelConfig,e.fields)),[c,l]=(0,L.useState)(null),u=pt(ft(e.channelName)),f=typeof i.enabled==`boolean`?i.enabled:!!e.channelConfig.enabled,p=t.isPending||!!c,m=(e,t)=>a(n=>({...n,[e]:t})),h=r=>{r.preventDefault();let a={...i};for(let t of e.fields){if(t.type===`password`){let e=a[t.name];(typeof e!=`string`||e.length===0)&&delete a[t.name]}if(t.type===`json`)try{a[t.name]=(o[t.name]??``).trim()?JSON.parse(o[t.name]):{}}catch{d.error(`${n(`invalidJson`)}: ${t.name}`);return}}t.mutate({channel:e.channelName,data:a})},g=t=>{if(!Q(t?.channels)||!Q(t.channels[e.channelName]))return;let n=t.channels[e.channelName];a(e=>$(e,n)),s(t=>{let r={...t},i=!1;for(let t of e.fields)t.type!==`json`||!Object.prototype.hasOwnProperty.call(n,t.name)||(r[t.name]=JSON.stringify(n[t.name]??{},null,2),i=!0);return i?r:t})},v=async o=>{l(o.id);try{let s=`channels.${e.channelName}`,c={...i};o.saveBeforeRun&&(c={...c,...o.savePatch??{}},a(c),await t.mutateAsync({channel:e.channelName,data:c}));let l=await r.mutateAsync({actionId:o.id,data:{scope:s,draftConfig:st(s,c)}});g(l.patch),l.ok?d.success(l.message||n(`success`)):d.error(l.message||n(`error`))}catch(e){d.error(`${n(`error`)}: ${e instanceof Error?e.message:String(e)}`)}finally{l(null)}};return(0,R.jsxs)(N,{children:[(0,R.jsx)(mt,{channelName:e.channelName,channelLabel:e.channelLabel,enabled:f,tutorialUrl:e.tutorialUrl,channelApplyStatus:u}),(0,R.jsxs)(`form`,{onSubmit:h,className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsx)(F,{className:`space-y-6 px-6 py-5`,children:(0,R.jsx)(ht,{channelConfig:e.channelConfig,channelName:e.channelName,enabled:f,fields:e.fields,formData:i,jsonDrafts:o,layoutBlocks:e.layoutBlocks,setJsonDrafts:s,uiHints:e.uiHints,updateField:m,disabled:p})}),(0,R.jsxs)(be,{className:`flex flex-wrap items-center justify-between gap-3 px-6 py-4`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.actions.filter(e=>e.trigger===`manual`).map(e=>(0,R.jsx)(_,{type:`button`,onClick:()=>void v(e),disabled:p,variant:`secondary`,children:c===e.id?n(`connecting`):e.title},e.id))}),(0,R.jsx)(_,{type:`submit`,disabled:p,children:t.isPending?n(`saving`):n(`save`)})]})]})]})}function _t({channelName:e}){let{data:t}=k(),{data:r}=A(),{data:i}=O(),a=e?t?.channels[e]??null:null,o=r?.channels.find(t=>t.name===e),s=(0,L.useMemo)(()=>it()[e||``],[e]);if(!e||!o||!a)return(0,R.jsx)(ve,{children:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold text-gray-900`,children:n(`channelsSelectTitle`)}),(0,R.jsx)(`p`,{className:`mt-2 text-sm text-gray-500`,children:n(`channelsSelectDescription`)})]})});let c=s?.fields??at,l=s?.layout??ot,u=i?.uiHints,d=M(`channels.${e}`,u)?.label??e,f=J(o),p=JSON.stringify({channelName:e,channelConfig:a,jsonFields:c.filter(e=>e.type===`json`).map(e=>e.name)});return(0,R.jsx)(gt,{actions:i?.actions?.filter(t=>t.scope===`channels.${e}`)??[],channelConfig:a,channelLabel:d,channelName:e,fields:c,layoutBlocks:l,tutorialUrl:f,uiHints:u},p)}var vt={telegram:`channelDescTelegram`,slack:`channelDescSlack`,email:`channelDescEmail`,webhook:`channelDescWebhook`,discord:`channelDescDiscord`,feishu:`channelDescFeishu`,weixin:`channelDescWeixin`},yt=[`weixin`,`feishu`,`discord`,`qq`];function bt(e){let t=new Map(yt.map((e,t)=>[e,t]));return e.map((e,t)=>({channel:e,index:t})).sort((e,n)=>{let r=t.get(e.channel.name)??1/0,i=t.get(n.channel.name)??1/0;return r===i?e.index-n.index:r-i}).map(({channel:e})=>e)}function xt(){let{isMobile:e}=fe(),{data:t}=k(),{data:r}=A(),{data:i}=O(),[a,o]=(0,L.useState)(`enabled`),[l,d]=(0,L.useState)(null),[f,p]=(0,L.useState)(``),h=(0,L.useMemo)(()=>bt(r?.channels??[]),[r?.channels]),g=t?.channels,_=(0,L.useMemo)(()=>{let e=f.trim().toLowerCase();return h.filter(e=>a!==`enabled`||!!g?.[e.name]?.enabled).filter(t=>e?(t.displayName||t.name).toLowerCase().includes(e)||t.name.toLowerCase().includes(e):!0)},[a,g,h,f]),v=l&&_.some(e=>e.name===l)?l:e?null:_[0]?.name??null;return!t||!r?(0,R.jsx)(`div`,{className:`p-8 text-gray-400`,children:n(`channelsLoading`)}):(0,R.jsxs)(m,{className:`pb-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col`,children:[(0,R.jsx)(u,{title:n(`channelsPageTitle`),description:n(`channelsPageDescription`)}),(0,R.jsxs)(_e,{className:`xl:min-h-0`,mobileView:e?v?`detail`:`list`:void 0,onMobileBack:()=>d(null),mobileListLabel:n(`channelsPageTitle`),children:[(0,R.jsxs)(N,{children:[(0,R.jsx)(P,{className:`px-4 pt-4`,children:(0,R.jsx)(he,{tabs:[{id:`enabled`,label:n(`channelsTabEnabled`),count:h.filter(e=>g?.[e.name]?.enabled).length},{id:`all`,label:n(`channelsTabAll`),count:h.length}],activeTab:a,onChange:o,className:`mb-0`})}),(0,R.jsx)(`div`,{className:`border-b border-gray-100 px-4 py-3`,children:(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(S,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,R.jsx)(c,{value:f,onChange:e=>p(e.target.value),placeholder:n(`channelsFilterPlaceholder`),className:`h-10 rounded-xl pl-9`})]})}),(0,R.jsxs)(F,{className:`space-y-2 p-3`,children:[_.map(e=>{let r=!!t.channels[e.name]?.enabled,a=J(e),o=M(`channels.${e.name}`,i?.uiHints)?.help||n(vt[e.name]||`channelDescriptionDefault`);return(0,R.jsx)(xe,{onClick:()=>d(e.name),active:v===e.name,children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,R.jsx)(j,{name:e.name,src:T(e.name),className:s(`h-10 w-10 rounded-lg border`,r?`border-primary/30 bg-white`:`border-gray-200/70 bg-white`),imgClassName:`h-5 w-5 object-contain`,fallback:(0,R.jsx)(`span`,{className:`text-sm font-semibold uppercase text-gray-500`,children:e.name[0]})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`p`,{className:`truncate text-sm font-semibold text-gray-900`,children:e.displayName||e.name}),(0,R.jsx)(`p`,{className:`line-clamp-1 text-[11px] text-gray-500`,children:o})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a?(0,R.jsx)(`a`,{href:a,onClick:e=>e.stopPropagation(),className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-300 transition-colors hover:bg-gray-100/70 hover:text-gray-500`,title:n(`channelsGuideTitle`),children:(0,R.jsx)(w,{className:`h-3.5 w-3.5`})}):null,(0,R.jsx)(D,{status:r?`active`:`inactive`,label:n(r?`statusActive`:`statusInactive`),className:`min-w-[56px] justify-center`})]})]})},e.name)}),_.length===0?(0,R.jsx)(ye,{icon:le,title:n(`channelsNoMatch`)}):null]})]}),(0,R.jsx)(_t,{channelName:v??void 0})]})]})}export{xt as ChannelsList};
|
|
@@ -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,Dt as s,Et as c,Ot as l,St as u,Tt as d,dt as f,ft as p,jt as m,kt as h,pt as g,wt as _}from"./api-BcqDx0tm.js";import{a as v,i as y,n as b,r as x,t as S}from"./select-DIZrwsKU.js";import{n as C,t as w}from"./refresh-cw-BxojR62w.js";import{t as T}from"./external-link-Sw3ah_JD.js";import{t as E}from"./rotate-cw-1Xqa7LZ8.js";var D=e(n(),1),O=i(),k={checking:`desktopUpdatesStatusChecking`,"update-available":`desktopUpdatesStatusAvailable`,downloading:`desktopUpdatesStatusDownloading`,downloaded:`desktopUpdatesStatusDownloaded`,"up-to-date":`desktopUpdatesStatusUpToDate`,blocked:`desktopUpdatesStatusBlocked`,failed:`desktopUpdatesStatusFailed`};function A({status:e}){return(0,O.jsx)(`span`,{className:a(`inline-flex rounded-full px-3 py-1 text-xs font-medium ring-1`,B(e)),children:z(e)})}function j({label:e,value:t}){return(0,O.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-gray-50/60 p-4`,children:[(0,O.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-[0.08em] text-gray-500`,children:e}),(0,O.jsx)(`p`,{className:`mt-2 text-base font-semibold text-gray-900`,children:t})]})}function M({snapshot:e}){if(e.status!==`downloading`)return null;let n=e.progress?.percent,r=n==null?t(`desktopUpdatesDownloadProgressUnknown`):t(`desktopUpdatesDownloadProgressPercent`).replace(`{percent}`,String(n)),i=I(e.progress?.downloadedBytes??0,e.progress?.totalBytes??null);return(0,O.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 p-4`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,O.jsx)(`p`,{className:`text-sm font-semibold text-amber-800`,children:r}),(0,O.jsx)(`p`,{className:`text-xs font-medium text-amber-700`,children:i})]}),(0,O.jsx)(`div`,{className:`mt-3 h-2 overflow-hidden rounded-full bg-amber-100`,children:(0,O.jsx)(`div`,{className:`h-full rounded-full bg-amber-500 transition-[width]`,style:{width:`${n??0}%`}})})]})}function N({label:e,help:t,checked:n,disabled:r,onCheckedChange:i}){return(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 rounded-xl border border-gray-200 p-4`,children:[(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(h,{children:e}),(0,O.jsx)(`p`,{className:`text-sm text-gray-500`,children:t})]}),(0,O.jsx)(f,{checked:n,disabled:r,onCheckedChange:i})]})}function P(e){return e?.trim()||`-`}function F(e){return e?r(e):`-`}function I(e,t){let n=L(e);return t&&t>0?`${n} / ${L(t)}`:n}function L(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;return`${n>=10||r===0?n.toFixed(0):n.toFixed(1)} ${t[r]}`}function R(e){return t(e===`beta`?`desktopUpdatesChannelBeta`:`desktopUpdatesChannelStable`)}function z(e){return t(k[e]??`desktopUpdatesStatusIdle`)}function B(e){return e===`downloaded`?`bg-emerald-50 text-emerald-700 ring-emerald-100`:e===`update-available`||e===`downloading`||e===`checking`?`bg-amber-50 text-amber-700 ring-amber-100`:e===`failed`||e===`blocked`?`bg-red-50 text-red-700 ring-red-100`:`bg-gray-100 text-gray-700 ring-gray-200`}function V(){return(0,O.jsxs)(l,{className:`space-y-6`,children:[(0,O.jsx)(s,{title:t(`runtimeUpdatesPageTitle`),description:t(`runtimeUpdatesPageDescription`)}),(0,O.jsxs)(u,{children:[(0,O.jsxs)(d,{children:[(0,O.jsx)(c,{children:t(`runtimeUpdatesUnavailableTitle`)}),(0,O.jsx)(_,{children:t(`runtimeUpdatesUnavailableDescription`)})]}),(0,O.jsx)(o,{children:(0,O.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`runtimeUpdatesUnavailableHint`)})})]})]})}function H(){let{supported:e,initialized:n,busyAction:r,snapshot:i}=g();if((0,D.useEffect)(()=>(p.start(),()=>{p.stop()}),[]),!n)return(0,O.jsx)(`div`,{className:`p-8 text-gray-400`,children:t(`loading`)});if(!e||!i)return(0,O.jsx)(V,{});let f=r===`checking`,k=r===`downloading`,I=r===`applying`,L=r===`saving-preferences`,z=r===`switching-channel`,B=i.status===`update-available`&&!k&&!I,H=i.status===`downloaded`&&!I,U=[[t(`runtimeUpdatesHostVersion`),P(i.hostVersion)],[t(`desktopUpdatesCurrentBundleVersion`),P(i.currentVersion)],[t(`desktopUpdatesAvailableVersion`),P(i.availableVersion)],[t(`desktopUpdatesLastCheckedAt`),F(i.lastCheckedAt)],[t(`desktopUpdatesCurrentChannel`),R(i.channel)]];return(0,O.jsxs)(l,{className:`space-y-6`,children:[(0,O.jsx)(s,{title:t(`runtimeUpdatesPageTitle`),description:t(`runtimeUpdatesPageDescription`),actions:(0,O.jsxs)(m,{variant:`outline`,onClick:()=>void p.checkForUpdates(),disabled:f||k||I,children:[(0,O.jsx)(w,{className:a(`mr-2 h-4 w-4`,f&&`animate-spin`)}),t(`desktopUpdatesCheckNow`)]})}),(0,O.jsxs)(u,{children:[(0,O.jsxs)(d,{children:[(0,O.jsx)(c,{children:t(`desktopUpdatesOverviewTitle`)}),(0,O.jsx)(_,{children:t(`desktopUpdatesOverviewDescription`)})]}),(0,O.jsxs)(o,{className:`space-y-5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-gray-700`,children:t(`desktopUpdatesStatusLabel`)}),(0,O.jsx)(A,{status:i.status})]}),(0,O.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-5`,children:U.map(([e,t])=>(0,O.jsx)(j,{label:e,value:t},e))}),i.channel===`beta`?(0,O.jsxs)(`div`,{className:`rounded-2xl border border-amber-200 bg-amber-50/70 p-4`,children:[(0,O.jsx)(`p`,{className:`text-sm font-semibold text-amber-800`,children:t(`desktopUpdatesBetaBadgeTitle`)}),(0,O.jsx)(`p`,{className:`mt-1 text-sm text-amber-700`,children:t(`desktopUpdatesBetaBadgeDescription`)})]}):null,i.downloadedVersion?(0,O.jsxs)(`div`,{className:`rounded-2xl border border-emerald-200 bg-emerald-50/70 p-4`,children:[(0,O.jsx)(`p`,{className:`text-sm font-semibold text-emerald-800`,children:t(`desktopUpdatesDownloadedBannerTitle`)}),(0,O.jsx)(`p`,{className:`mt-1 text-sm text-emerald-700`,children:t(`runtimeUpdatesDownloadedBannerDescription`).replace(`{version}`,i.downloadedVersion)})]}):null,(0,O.jsx)(M,{snapshot:i}),i.status===`blocked`?(0,O.jsxs)(`div`,{className:`rounded-2xl border border-red-200 bg-red-50/70 p-4`,children:[(0,O.jsx)(`p`,{className:`text-sm font-semibold text-red-800`,children:t(`desktopUpdatesBlockedTitle`)}),(0,O.jsx)(`p`,{className:`mt-1 text-sm text-red-700`,children:i.errorMessage??t(`desktopUpdatesBlockedDescription`)}),i.recoveryCommand?(0,O.jsx)(`code`,{className:`mt-3 block rounded-lg bg-white/70 px-3 py-2 text-xs text-red-800`,children:i.recoveryCommand}):null]}):null,i.errorMessage&&i.status!==`blocked`?(0,O.jsx)(`div`,{className:`rounded-2xl border border-red-200 bg-red-50/70 p-4 text-sm text-red-700`,children:i.errorMessage}):null]})]}),(0,O.jsxs)(u,{children:[(0,O.jsxs)(d,{children:[(0,O.jsx)(c,{children:t(`desktopUpdatesPreferencesTitle`)}),(0,O.jsx)(_,{children:t(`desktopUpdatesPreferencesDescription`)})]}),(0,O.jsxs)(o,{className:`space-y-5`,children:[(0,O.jsx)(`div`,{className:`rounded-xl border border-gray-200 p-4`,children:(0,O.jsxs)(`div`,{className:`space-y-3`,children:[(0,O.jsxs)(`div`,{className:`space-y-1`,children:[(0,O.jsx)(h,{children:t(`desktopUpdatesReleaseChannel`)}),(0,O.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`desktopUpdatesReleaseChannelHelp`)})]}),(0,O.jsxs)(S,{value:i.channel,disabled:z||f||k||I,onValueChange:e=>void p.updateChannel(e),children:[(0,O.jsx)(y,{className:`w-full max-w-sm`,children:(0,O.jsx)(v,{placeholder:t(`desktopUpdatesReleaseChannel`)})}),(0,O.jsxs)(b,{children:[(0,O.jsx)(x,{value:`stable`,children:t(`desktopUpdatesChannelStable`)}),(0,O.jsx)(x,{value:`beta`,children:t(`desktopUpdatesChannelBeta`)})]})]}),(0,O.jsx)(`p`,{className:`text-sm text-gray-500`,children:t(`desktopUpdatesReleaseChannelDowngradeHint`)})]})}),(0,O.jsx)(N,{label:t(`desktopUpdatesAutomaticChecks`),help:t(`desktopUpdatesAutomaticChecksHelp`),checked:i.preferences.automaticChecks,disabled:L||z,onCheckedChange:e=>void p.updatePreferences({automaticChecks:e})}),(0,O.jsx)(N,{label:t(`desktopUpdatesAutoDownload`),help:t(`desktopUpdatesAutoDownloadHelp`),checked:i.preferences.autoDownload,disabled:L||z,onCheckedChange:e=>void p.updatePreferences({autoDownload:e})})]})]}),(0,O.jsxs)(u,{children:[(0,O.jsxs)(d,{children:[(0,O.jsx)(c,{children:t(`desktopUpdatesActionsTitle`)}),(0,O.jsx)(_,{children:t(`runtimeUpdatesActionsDescription`)})]}),(0,O.jsxs)(o,{className:`flex flex-wrap items-center gap-3`,children:[(0,O.jsxs)(m,{variant:`outline`,onClick:()=>void p.checkForUpdates(),disabled:f||k||I,children:[(0,O.jsx)(w,{className:a(`mr-2 h-4 w-4`,f&&`animate-spin`)}),t(`desktopUpdatesCheckNow`)]}),(0,O.jsxs)(m,{onClick:()=>void p.downloadUpdate(),disabled:!B,children:[(0,O.jsx)(C,{className:a(`mr-2 h-4 w-4`,k&&`animate-bounce`)}),t(`desktopUpdatesDownloadNow`)]}),(0,O.jsxs)(m,{variant:`secondary`,onClick:()=>void p.applyDownloadedUpdate(),disabled:!H,children:[(0,O.jsx)(E,{className:a(`mr-2 h-4 w-4`,I&&`animate-spin`)}),t(`runtimeUpdatesApplyNow`)]}),i.releaseNotesUrl?(0,O.jsxs)(m,{variant:`ghost`,onClick:()=>window.open(i.releaseNotesUrl??``,`_blank`,`noopener,noreferrer`),children:[(0,O.jsx)(T,{className:`mr-2 h-4 w-4`}),t(`desktopUpdatesReleaseNotes`)]}):null]})]})]})}export{H as DesktopUpdateConfig};
|
|
@@ -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-PccJ9XyH.js","assets/api-BcqDx0tm.js","assets/provider-scoped-model-input-CzpF7cug.js","assets/select-DIZrwsKU.js","assets/es2015-JCM5-KtW.js","assets/folder-D7-VTnkz.js","assets/loader-circle-B5i8oMMY.js","assets/sparkles-D1ZKWdm4.js","assets/skeleton-CFQRIUzt.js","assets/use-config-BQJjq1mP.js","assets/config-hints-MogHYQ8G.js","assets/chat-page-BxlXY-MB.js","assets/chunk-JZWAC4HX-u4uYphxM.js","assets/chat-ahMH_i_K.js","assets/dialog-csshWetU.js","assets/dist-Bl94Ahwx.js","assets/popover-YAsxDBhY.js","assets/tooltip-Dq5Xehpk.js","assets/theme-provider-W704JWF8.js","assets/refresh-cw-BxojR62w.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-BX3XqzJ4.js","assets/logo-badge-BQgKnVtz.js","assets/mcp-marketplace-page-5UjYRWOR.js","assets/use-infinite-scroll-loader-JAicqVC5.js","assets/use-confirm-dialog-DBoV5n5P.js","assets/notice-card-CCgk6FvF.js","assets/tag-chip-C3wDBe_-.js","assets/play-D8WJLnJe.js","assets/marketplace-page-DxlxHCFm.js","assets/tabs-custom-CsACkVji.js","assets/search-config-D3a65l3r.js","assets/key-round-CnI1mc9F.js","assets/config-split-page-BMRGuCJQ.js","assets/providers-list-8qDMER8o.js","assets/setting-row-DiQyrE81.js","assets/status-dot-Dv_hiUVa.js","assets/channels-list-page-CsoI4OJm.js","assets/hash-zajSTDXZ.js","assets/message-square-D6Z4NwpG.js","assets/runtime-config-page-DWJHrV7H.js","assets/rotate-cw-1Xqa7LZ8.js","assets/save--BVI5wZX.js","assets/desktop-update-config-CD6-2PfI.js","assets/sessions-config-page-QjH5tgjr.js","assets/secrets-config-CoMlR_7i.js","assets/remote-D4TtLPAp.js","assets/app-manager-provider-DVYBjif-.js","assets/marketplace-page-DJGDpTAo.js","assets/mcp-marketplace-page-C1XaHZZO.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{Ft as s,Gt as c,Nt as l,Pt as u,_t as d,bt as f,ct as p,d as m,ft as h,lt as g,ot as _,yt as v,zt as y}from"./api-BcqDx0tm.js";import{a as b,c as x,i as S,n as C,o as ee,r as w,s as T,t as te,u as E}from"./chunk-JZWAC4HX-u4uYphxM.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-W704JWF8.js";import{n as P}from"./search-vChioOoe.js";import{f as de,l as fe}from"./chat-ahMH_i_K.js";import{t as pe}from"./book-open-DgLqYpNY.js";import{k as F,r as I}from"./select-DIZrwsKU.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-BOVDFMnp.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-DVYBjif-.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-BX3XqzJ4.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=c();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}),s.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}),s.success(r(`runtimePresenceSaved`)),n}catch(e){throw s.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}),s.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`){s.success(r(`desktopUpdatesAlreadyLatest`));return}if(e.status===`update-available`){s.success(r(`desktopUpdatesAvailable`).replace(`{version}`,e.availableVersion??r(`desktopUpdatesUnknownVersion`)));return}if(e.status===`downloaded`){s.success(r(`desktopUpdatesReadyToApply`));return}e.status===`failed`&&e.errorMessage&&s.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`&&s.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){s.success(r(`desktopUpdatesChannelChangedWithUpdate`).replace(`{channel}`,this.getChannelLabel(e)).replace(`{version}`,t.availableVersion));return}s.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 s.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 E(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)(C,{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=x(),{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 E(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=x();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)(S,{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`){v.handleConnectionRestored(),n&&(r(),t?.invalidateQueries({queryKey:[`ncp-sessions`]}));return}if(a.type===`connection.close`||a.type===`connection.error`){v.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`){m(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)(()=>_.realtime.subscribe(n=>Ze({queryClient:e,shouldResyncSessions:t.current,clearShouldResyncSessions:()=>{t.current=!1},markShouldResyncSessions:()=>{t.current=!0},event:n})).close,[e])}var $e=(0,W.lazy)(async()=>({default:(await E(async()=>{let{ModelConfig:e}=await import(`./model-config-PccJ9XyH.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 E(async()=>{let{ChatPage:e}=await import(`./chat-page-BxlXY-MB.js`);return{ChatPage:e}},__vite__mapDeps([21,2,22,13,14,11,3,23,24,25,8,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 E(async()=>{let{SearchConfig:e}=await import(`./search-config-D3a65l3r.js`);return{SearchConfig:e}},__vite__mapDeps([45,2,13,14,11,3,4,6,46,35,47,19]))).SearchConfig})),tt=(0,W.lazy)(async()=>({default:(await E(async()=>{let{ProvidersList:e}=await import(`./providers-list-8qDMER8o.js`);return{ProvidersList:e}},__vite__mapDeps([48,2,13,14,11,3,26,25,4,46,7,33,8,35,36,47,49,50,44,19,20]))).ProvidersList})),nt=(0,W.lazy)(async()=>({default:(await E(async()=>{let{ChannelsList:e}=await import(`./channels-list-page-CsoI4OJm.js`);return{ChannelsList:e}},__vite__mapDeps([51,2,13,14,11,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 E(async()=>{let{RuntimeConfig:e}=await import(`./runtime-config-page-DWJHrV7H.js`);return{RuntimeConfig:e}},__vite__mapDeps([54,2,13,14,11,3,28,22,26,25,29,8,19,16,42,7,55,56,33,40,49,20]))).RuntimeConfig})),Z=(0,W.lazy)(async()=>({default:(await E(async()=>{let{DesktopUpdateConfig:e}=await import(`./desktop-update-config-CD6-2PfI.js`);return{DesktopUpdateConfig:e}},__vite__mapDeps([57,2,13,14,11,3,29,6,55]))).DesktopUpdateConfig})),it=(0,W.lazy)(async()=>({default:(await E(async()=>{let{SecurityConfig:e}=await import(`./api-BcqDx0tm.js`).then(e=>e.st);return{SecurityConfig:e}},__vite__mapDeps([11,2]))).SecurityConfig})),at=(0,W.lazy)(async()=>({default:(await E(async()=>{let{SessionsConfig:e}=await import(`./sessions-config-page-QjH5tgjr.js`);return{SessionsConfig:e}},__vite__mapDeps([58,2,13,14,11,3,23,24,25,8,26,27,28,22,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 E(async()=>{let{SecretsConfig:e}=await import(`./secrets-config-CoMlR_7i.js`);return{SecretsConfig:e}},__vite__mapDeps([59,2,13,14,11,3,7,56,33,19]))).SecretsConfig})),st=(0,W.lazy)(async()=>({default:(await E(async()=>{let{RemoteAccessPage:e}=await import(`./remote-D4TtLPAp.js`);return{RemoteAccessPage:e}},__vite__mapDeps([60,61,2,24,14,11,25,8,3,46,31,40,50]))).RemoteAccessPage})),ct=(0,W.lazy)(async()=>({default:(await E(async()=>{let{MarketplacePage:e}=await import(`./marketplace-page-DJGDpTAo.js`);return{MarketplacePage:e}},__vite__mapDeps([62,43,2,22,27,13,14,11,3,25,38,18,34,1,4,5,6,7,8,9,39,24,44]))).MarketplacePage})),lt=(0,W.lazy)(async()=>({default:(await E(async()=>{let{McpMarketplacePage:e}=await import(`./mcp-marketplace-page-C1XaHZZO.js`);return{McpMarketplacePage:e}},__vite__mapDeps([63,37,2,24,14,11,25,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)(b,{path:e.path,element:(0,J.jsx)(S,{to:e.redirectTo,replace:!0})},e.path):(0,J.jsx)(b,{path:e.path,element:e.element},e.path)}function mt(){return(0,J.jsx)(ee,{children:ft.map(pt)})}function $(){return Qe(l),d(),(0,W.useEffect)(()=>(h.start(),()=>{h.stop()}),[]),(0,J.jsxs)(Se,{children:[(0,J.jsx)(Ke,{children:(0,J.jsx)(mt,{})}),(0,J.jsx)(ye,{})]})}function ht(){let e=g(),t=e.isError&&p(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)(y,{client:l,children:[(0,J.jsx)(ht,{}),(0,J.jsx)(j,{}),(0,J.jsx)(ae,{}),(0,J.jsx)(u,{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)(te,{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-DxlxHCFm.js";export{e as MarketplacePage};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import{_ as e,i as t,m as n,p as r,u as i}from"./i18n-C5Mibli1.js";import{At as a,Bt as o,C as s,Ft as c,It as l,Lt as u,Ot as d,S as f,T as p,b as m,dt as h,jt as g,w as _,x as v}from"./api-BcqDx0tm.js";import{a as y,c as b,i as x,l as S,n as C,o as w,r as T,s as ee,t as E}from"./use-infinite-scroll-loader-JAicqVC5.js";import{a as D,i as O,n as k,o as A,r as j,t as M}from"./dialog-csshWetU.js";import{t as N}from"./createLucideIcon-BZkY6emz.js";import{t as te}from"./sparkles-D1ZKWdm4.js";import{t as P}from"./notice-card-CCgk6FvF.js";import{i as F}from"./doc-browser-context-DfLHAWbG.js";import{n as I}from"./doc-browser-BUlCkZo2.js";import{t as L}from"./tag-chip-C3wDBe_-.js";import{t as R}from"./use-confirm-dialog-DBoV5n5P.js";var z=N(`PackageCheck`,[[`path`,{d:`m16 16 2 2 4-4`,key:`gfu2re`}],[`path`,{d:`M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14`,key:`e7tb2h`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}],[`polyline`,{points:`3.29 7 12 12 20.71 7`,key:`ousv84`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`12`,key:`a4e8g8`}]]);function B(e){return(e??``).trim().toLowerCase()}function ne(e){let t=new Map;for(let n of e){let e=[n.catalogSlug,n.spec,n.id,n.label];for(let r of e){let e=B(r);!e||t.has(e)||t.set(e,n)}}return t}function re(e,t){let n=[e.slug,e.install.spec,e.id,e.name];for(let e of n){let n=B(e);if(!n)continue;let r=t.get(n);if(r)return r}}function V(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function H(e,t,n,r,i){let a=`<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<title>${V(e)}</title>
|
|
7
|
-
<style>
|
|
8
|
-
body { margin: 0; background: #f8fafc; color: #0f172a; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
|
|
9
|
-
.wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 40px; }
|
|
10
|
-
.hero { border: 1px solid #dbeafe; border-radius: 16px; background: linear-gradient(180deg, #eff6ff, #ffffff); padding: 20px; }
|
|
11
|
-
.hero h1 { margin: 0; font-size: 26px; }
|
|
12
|
-
.grid { display: grid; grid-template-columns: 280px 1fr; gap: 14px; margin-top: 16px; }
|
|
13
|
-
.card { border: 1px solid #e2e8f0; background: #fff; border-radius: 14px; overflow: hidden; }
|
|
14
|
-
.card h2 { margin: 0; padding: 12px 14px; font-size: 13px; font-weight: 700; color: #1d4ed8; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
|
|
15
|
-
.body { padding: 12px 14px; }
|
|
16
|
-
pre { margin: 0; white-space: pre-wrap; line-height: 1.7; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
|
|
17
|
-
a { color: #2563eb; text-decoration: none; }
|
|
18
|
-
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }
|
|
19
|
-
</style>
|
|
20
|
-
</head>
|
|
21
|
-
<body>
|
|
22
|
-
<main class="wrap">
|
|
23
|
-
<section class="hero">
|
|
24
|
-
<h1>${V(e)}</h1>
|
|
25
|
-
${i?`<p>${V(i)}</p>`:``}
|
|
26
|
-
${r?`<p><a href="${V(r)}" target="_blank" rel="noopener noreferrer">${V(r)}</a></p>`:``}
|
|
27
|
-
</section>
|
|
28
|
-
<section class="grid">
|
|
29
|
-
<article class="card">
|
|
30
|
-
<h2>Metadata</h2>
|
|
31
|
-
<div class="body"><pre>${V(t)}</pre></div>
|
|
32
|
-
</article>
|
|
33
|
-
<article class="card">
|
|
34
|
-
<h2>Content</h2>
|
|
35
|
-
<div class="body"><pre>${V(n)}</pre></div>
|
|
36
|
-
</article>
|
|
37
|
-
</section>
|
|
38
|
-
</main>
|
|
39
|
-
</body>
|
|
40
|
-
</html>`;return`data:text/html;charset=utf-8,${encodeURIComponent(a)}`}function U(e,n,r){return x(n?.summaryI18n,n?.summary,e)||T(r,e)||t(`marketplaceInstalledLocalSummary`)}function W(e,t){return t?.transport?t.transport.toUpperCase():(e?.install?.transportTypes??[]).map(e=>e.toUpperCase()).join(` / `)||`MCP`}var G=r();function K(e){let{item:n,record:r,localeFallbacks:i,onOpen:a,onInstall:o,onToggle:s,onDoctor:c,onRemove:l}=e,u=r,d=n?.name??r?.label??r?.id??`MCP`,f=U(i,n,r),p=W(n,r),m=u?u.enabled===!1?t(`marketplaceDisable`):t(`statusReady`):null;return(0,G.jsx)(`article`,{onClick:a,className:`cursor-pointer rounded-2xl border border-gray-200/70 bg-white p-4 shadow-sm transition hover:border-blue-300 hover:shadow-md`,children:(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-sm font-semibold text-gray-900`,children:d}),(0,G.jsx)(`div`,{className:`mt-1 text-xs text-gray-500`,children:p}),(0,G.jsx)(`div`,{className:`mt-2 line-clamp-2 text-sm text-gray-600`,children:f}),(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(n?.tags??[]).map(e=>(0,G.jsx)(L,{children:e},e)),m?(0,G.jsx)(L,{tone:`success`,children:m}):null]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2`,children:[!u&&n&&o?(0,G.jsx)(g,{type:`button`,size:`sm`,variant:`primary`,className:`rounded-xl`,onClick:e=>{e.stopPropagation(),o()},children:t(`marketplaceInstall`)}):null,u?(0,G.jsxs)(G.Fragment,{children:[s?(0,G.jsx)(g,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-gray-200 text-gray-700`,onClick:e=>{e.stopPropagation(),s()},children:u.enabled===!1?t(`marketplaceEnable`):t(`marketplaceDisable`)}):null,c?(0,G.jsx)(g,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-blue-200 text-blue-700 hover:border-blue-300 hover:bg-blue-50 hover:text-blue-700`,onClick:e=>{e.stopPropagation(),c()},children:t(`marketplaceMcpDoctor`)}):null,l?(0,G.jsx)(g,{type:`button`,size:`sm`,variant:`outline`,className:`rounded-xl border-rose-200 text-rose-600 hover:border-rose-300 hover:bg-rose-50 hover:text-rose-600`,onClick:e=>{e.stopPropagation(),l()},children:t(`marketplaceMcpRemove`)}):null]}):null]})]})})}var q=e(n(),1);function J(e){let{item:t,open:n,pending:r,onOpenChange:i,onSubmit:a}=e;return(0,G.jsx)(M,{open:n,onOpenChange:i,children:t?(0,G.jsx)(Y,{item:t,pending:r,onOpenChange:i,onSubmit:a},`${t.slug}:${n?`open`:`closed`}`):null})}function Y(e){let{item:n,pending:r,onOpenChange:i,onSubmit:o}=e,s=n.install,[c,l]=(0,q.useState)(s?.defaultName??``),[u,d]=(0,q.useState)(!0),[f,p]=(0,q.useState)(Object.fromEntries((s?.inputs??[]).map(e=>[e.id,e.defaultValue??``])));return(0,G.jsxs)(k,{children:[(0,G.jsxs)(D,{children:[(0,G.jsx)(A,{children:t(`marketplaceMcpInstallDialogTitle`)}),(0,G.jsx)(j,{children:n.name})]}),(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:t(`marketplaceMcpServerName`)}),(0,G.jsx)(a,{value:c,onChange:e=>l(e.target.value),placeholder:s?.defaultName??`mcp-server`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between rounded-xl border border-gray-200 px-3 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-gray-900`,children:t(`marketplaceMcpAllAgents`)}),(0,G.jsx)(`div`,{className:`text-xs text-gray-500`,children:t(`marketplaceMcpAllAgentsDescription`)})]}),(0,G.jsx)(h,{checked:u,onCheckedChange:d})]}),(s?.inputs??[]).map(e=>(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-gray-800`,children:e.label}),e.description?(0,G.jsx)(`div`,{className:`text-xs text-gray-500`,children:e.description}):null,(0,G.jsx)(a,{type:e.secret?`password`:`text`,value:f[e.id]??``,onChange:t=>p(n=>({...n,[e.id]:t.target.value})),placeholder:e.defaultValue??``})]},e.id))]}),(0,G.jsxs)(O,{children:[(0,G.jsx)(g,{variant:`outline`,onClick:()=>i(!1),disabled:r,children:t(`cancel`)}),(0,G.jsx)(g,{onClick:()=>void o({name:c,allAgents:u,inputs:f}),disabled:r||!c.trim(),children:t(r?`marketplaceInstalling`:`marketplaceInstall`)})]})]})}function X(e){let{result:n,targetName:r,open:i,pending:a,onOpenChange:o}=e;return(0,G.jsx)(M,{open:i,onOpenChange:o,children:(0,G.jsxs)(k,{children:[(0,G.jsxs)(D,{children:[(0,G.jsx)(A,{children:t(`marketplaceMcpDoctorTitle`)}),(0,G.jsx)(j,{children:r??`-`})]}),a?(0,G.jsx)(`div`,{className:`text-sm text-gray-500`,children:t(`loading`)}):null,!a&&n?(0,G.jsxs)(`div`,{className:`space-y-3 text-sm text-gray-700`,children:[(0,G.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorAccessible`),`:`,` `,n.accessible?t(`statusReady`):t(`marketplaceOperationFailed`)]}),(0,G.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorTransport`),`:`,` `,n.transport.toUpperCase()]}),(0,G.jsxs)(`div`,{children:[t(`marketplaceMcpDoctorTools`),`: `,n.toolCount]}),n.error?(0,G.jsx)(P,{tone:`danger`,description:n.error,className:`rounded-lg`}):null]}):null]})})}function ie(e){let t=S({queryKey:[`marketplace-mcp-items`,e],initialPageParam:1,queryFn:({pageParam:t})=>s({...e,page:t}),getNextPageParam:e=>e.page<e.totalPages?e.page+1:void 0,staleTime:15e3}),n=(0,q.useMemo)(()=>b(t.data),[t.data]);return{...t,data:n}}function ae(){return u({queryKey:[`marketplace-mcp-installed`],queryFn:()=>f(),staleTime:1e4})}function oe(){let e=o();return l({mutationFn:_,onSuccess:n=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),c.success(n.message||t(`marketplaceInstallSuccessMcp`))},onError:e=>{c.error(e.message||t(`marketplaceInstallFailed`))}})}function se(){let e=o();return l({mutationFn:p,onSuccess:n=>{e.invalidateQueries({queryKey:[`marketplace-mcp-installed`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-items`]}),e.invalidateQueries({queryKey:[`marketplace-mcp-doctor`]}),c.success(n.message||t(`marketplaceMcpManageSuccess`))},onError:e=>{c.error(e.message||t(`marketplaceOperationFailed`))}})}var Z=12;function Q(){let[e,n]=(0,q.useState)(`catalog`),[r,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(``),[c,u]=(0,q.useState)(`relevance`),[f,p]=(0,q.useState)(null),[h,g]=(0,q.useState)(null),[_,b]=(0,q.useState)(null),{language:x}=I(),S=F(),{confirm:T,ConfirmDialog:D}=R(),O=(0,q.useMemo)(()=>C(x),[x]);(0,q.useEffect)(()=>{let e=window.setTimeout(()=>{s(r.trim())},250);return()=>window.clearTimeout(e)},[r]);let k=ie({q:o||void 0,sort:c,pageSize:Z}),A=ae(),{containerRef:j,sentinelRef:M}=E({disabled:e!==`catalog`||k.isError||!k.hasNextPage||k.isFetchingNextPage,onLoadMore:()=>k.fetchNextPage(),watchValue:`${e}:${o}:${c}:${k.data?.loadedItems??0}:${k.data?.loadedPages??0}`});(0,q.useEffect)(()=>{let e=j.current;e&&typeof e.scrollTo==`function`&&e.scrollTo({top:0})},[j,o,e,c]);let N=oe(),L=se(),B=l({mutationFn:m,onSuccess:(e,t)=>{g(t),b(e)}}),V=(0,q.useMemo)(()=>ne(A.data?.records??[]),[A.data?.records]),W=(0,q.useMemo)(()=>(A.data?.records??[]).filter(e=>{let t=[e.id??``,e.label??``,e.catalogSlug??``,e.description??``,e.descriptionZh??``].join(` `).toLowerCase();return o?t.includes(o.toLowerCase()):!0}),[A.data?.records,o]),Y=async(e,n)=>{let r=e?.name??n?.label??n?.id??`MCP`,i={title:r,kind:`content`,dedupeKey:e?`marketplace:mcp:${e.slug}`:`marketplace:mcp:${n?.id??n?.spec??r}`},a=U(O,e,n);if(!e){let e=H(r,JSON.stringify(n??{},null,2),t(`marketplaceInstalledLocalSummary`),n?.docsUrl,a);S.open(e,i);return}try{let t=await v(e.slug),n=H(r,t.metadataRaw||JSON.stringify(e,null,2),t.bodyRaw||t.raw,t.sourceUrl,a);S.open(n,i)}catch(e){let t=H(r,JSON.stringify({error:e instanceof Error?e.message:String(e)},null,2),a,void 0,a);S.open(t,i)}},Q=async e=>{f&&(await N.mutateAsync({spec:f.slug,name:e.name.trim(),allAgents:e.allAgents,inputs:e.inputs}),p(null))},$=async(e,n)=>{let r=n.id||n.spec;r&&(e===`remove`&&!await T({title:`${t(`marketplaceMcpRemoveTitle`)} ${r}?`,description:t(`marketplaceMcpRemoveDescription`),confirmLabel:t(`marketplaceMcpRemove`),variant:`destructive`})||await L.mutateAsync({action:e,id:r,spec:n.spec}))},ce=[{id:`catalog`,label:t(`marketplaceMcpTabCatalog`),icon:te},{id:`installed`,label:t(`marketplaceMcpTabInstalled`),icon:z,count:A.data?.total??0}];return(0,G.jsxs)(d,{className:`flex h-full min-h-0 flex-col pb-0 px-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 w-full max-w-[1400px] h-full min-h-0 mx-auto`,children:[(0,G.jsxs)(`div`,{className:`relative overflow-hidden rounded-[32px] bg-gradient-to-br from-[#0F172A] via-[#1E1B4B] to-[#312E81] px-10 py-14 text-white shadow-xl isolate`,children:[(0,G.jsx)(`div`,{className:`absolute top-0 right-0 -m-32 opacity-30 pointer-events-none mix-blend-screen scale-150 transform-gpu`,children:(0,G.jsx)(`div`,{className:`w-[500px] h-[500px] rounded-full bg-gradient-to-tl from-fuchsia-500/40 via-purple-500/30 to-indigo-500/20 blur-[80px]`})}),(0,G.jsx)(`div`,{className:`absolute bottom-0 left-0 -m-32 opacity-20 pointer-events-none mix-blend-screen transform-gpu`,children:(0,G.jsx)(`div`,{className:`w-[400px] h-[400px] rounded-full bg-gradient-to-tr from-blue-500/40 to-cyan-500/20 blur-[80px]`})}),(0,G.jsxs)(`div`,{className:`relative z-10 flex flex-col gap-3`,children:[(0,G.jsx)(`h1`,{className:`text-[38px] font-extrabold tracking-[-0.02em] leading-tight drop-shadow-sm text-transparent bg-clip-text bg-gradient-to-r from-white via-white to-white/70`,children:t(`marketplaceMcpPageTitle`)}),(0,G.jsx)(`p`,{className:`text-[17px] font-medium text-purple-100/70 max-w-2xl leading-relaxed tracking-wide`,children:t(`marketplaceMcpPageDescription`)})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4 mt-2`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-gray-100/60 backdrop-blur-sm rounded-2xl w-fit border border-gray-200/50 shadow-inner`,children:ce.map(t=>{let r=e===t.id,a=t.icon;return(0,G.jsxs)(`button`,{onClick:()=>n(t.id),className:i(`relative flex items-center gap-2 px-5 py-2.5 rounded-xl font-semibold text-[14px] transition-all duration-300`,r?`text-gray-900 bg-white shadow-[0_2px_10px_rgb(0,0,0,0.06)]`:`text-gray-500 hover:text-gray-700 hover:bg-gray-200/40`),children:[(0,G.jsx)(a,{className:i(`w-4 h-4`,r?`text-primary`:`text-gray-400`)}),t.label,t.id===`installed`&&typeof t.count==`number`&&(0,G.jsx)(`span`,{className:i(`ml-1 flex items-center justify-center h-5 px-1.5 min-w-5 rounded-full text-[11px] font-bold transition-colors`,r?`bg-primary/10 text-primary`:`bg-gray-200 text-gray-500`),children:t.count})]},t.id)})}),(0,G.jsx)(`div`,{className:`flex-1 w-full md:max-w-md`,children:(0,G.jsx)(y,{scope:e===`catalog`?`all`:`installed`,searchText:r,searchPlaceholder:t(`marketplaceMcpSearchPlaceholder`),sort:c,onSearchTextChange:a,onSortChange:u})})]}),(0,G.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col mt-2`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between mb-4 px-1`,children:(0,G.jsxs)(`h3`,{className:`text-[18px] font-bold tracking-tight text-gray-900 flex items-center gap-2`,children:[t(e===`catalog`?`marketplaceMcpSectionCatalog`:`marketplaceMcpSectionInstalled`),(0,G.jsx)(`span`,{className:`flex items-center justify-center h-6 px-2 rounded-lg bg-gray-100 text-[12px] font-semibold text-gray-500`,children:e===`catalog`?k.data?.total??0:A.data?.total??0})]})}),(0,G.jsxs)(`div`,{ref:j,className:`min-h-0 flex-1 overflow-y-auto pr-3 pb-8 -mx-1 px-1 custom-scrollbar`,"aria-busy":k.isLoading||k.isFetchingNextPage,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-[22px] md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 items-stretch`,children:[e===`catalog`&&k.isLoading&&(0,G.jsx)(ee,{count:Z}),e===`catalog`&&!k.isLoading&&(k.data?.items??[]).map(e=>{let t=re(e,V);return(0,G.jsx)(K,{item:e,record:t,localeFallbacks:O,onOpen:()=>void Y(e,t),onInstall:()=>p(e),onToggle:t?()=>void $(t.enabled===!1?`enable`:`disable`,t):void 0,onDoctor:t?()=>{g(t.id??null),b(null),B.mutateAsync(t.id??``)}:void 0,onRemove:t?()=>void $(`remove`,t):void 0},e.id)}),e===`installed`&&W.map(e=>(0,G.jsx)(K,{record:e,localeFallbacks:O,onOpen:()=>void Y(void 0,e),onToggle:()=>void $(e.enabled===!1?`enable`:`disable`,e),onDoctor:()=>{g(e.id??null),b(null),B.mutateAsync(e.id??``)},onRemove:()=>void $(`remove`,e)},e.id??e.spec))]}),e===`catalog`&&k.isError&&(0,G.jsx)(P,{tone:`danger`,title:t(`marketplaceMcpSectionCatalog`),description:k.error.message}),e===`installed`&&A.isError&&(0,G.jsx)(P,{tone:`danger`,title:t(`marketplaceMcpSectionInstalled`),description:A.error.message}),e===`catalog`&&!k.isLoading&&!k.isError&&(k.data?.items?.length??0)===0&&(0,G.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,G.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:t(`marketplaceNoMcp`)})}),e===`installed`&&!A.isError&&W.length===0&&(0,G.jsx)(`div`,{className:`flex flex-col items-center justify-center py-20 bg-gray-50/50 rounded-3xl border border-dashed border-gray-200 mt-4`,children:(0,G.jsx)(`p`,{className:`text-[15px] font-medium text-gray-500`,children:t(`marketplaceNoInstalledMcp`)})}),e===`catalog`&&!k.isError&&(0,G.jsx)(w,{hasMore:!!k.hasNextPage,loading:k.isFetchingNextPage,sentinelRef:M})]})]})]}),(0,G.jsx)(J,{item:f,open:!!f,pending:N.isPending,onOpenChange:e=>!e&&p(null),onSubmit:Q}),(0,G.jsx)(X,{open:!!h,targetName:h,result:_,pending:B.isPending,onOpenChange:e=>!e&&g(null)}),(0,G.jsx)(D,{})]})}export{Q as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./mcp-marketplace-page-5UjYRWOR.js";export{e as McpMarketplacePage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as e}from"./app-manager-provider-DVYBjif-.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{At as i,Ct as a,Dt as o,Et as s,Ft as c,Ot as l,St as u,Tt as d,dt as f,gt as p,jt as m,mt as h,wt as g,yt as _}from"./api-BcqDx0tm.js";import{t as v}from"./createLucideIcon-BZkY6emz.js";import{a as y}from"./theme-provider-W704JWF8.js";import{a as b,i as x,n as S,r as C,t as w}from"./select-DIZrwsKU.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-CCgk6FvF.js";import{i as k,n as A,w as j}from"./use-config-BQJjq1mP.js";import{n as M,r as N}from"./index-CM-57d8J.js";import{t as P}from"./config-hints-MogHYQ8G.js";import{t as F}from"./setting-row-DiQyrE81.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:i,pendingRestart:o,visibleLifecycle:l,visibleMessage:f,visibleServiceState:p}=h(),v=G(r??void 0),y=async e=>{let n=W(r,e);if(!n?.available){c.error(n?.reasonIfUnavailable??t(`runtimeControlLoadFailed`));return}if(!(e===`stop-service`&&n.requiresConfirmation&&!window.confirm(t(`runtimeControlStopServiceConfirm`))))try{let t=await _.runRuntimeControlAction(e);c.success(t.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}},b=async()=>{if(!r?.canRestartApp.available){c.error(r?.canRestartApp.reasonIfUnavailable??t(`runtimeRestartAppUnavailable`));return}if(window.confirm(t(`runtimeControlRestartAppConfirm`)))try{let e=await _.runRuntimeControlAction(`restart-app`);c.success(e.message)}catch(e){let n=e instanceof Error?e.message:t(`runtimeControlActionFailed`);c.error(`${t(`runtimeControlActionFailed`)}: ${n}`)}};return(0,L.jsxs)(u,{children:[(0,L.jsxs)(d,{children:[(0,L.jsx)(s,{children:t(`runtimeControlTitle`)}),(0,L.jsx)(g,{children:t(`runtimeControlDescription`)})]}),(0,L.jsxs)(a,{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(p)}),(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:f}),(0,L.jsx)(`div`,{className:`text-xs text-gray-500`,children:V(l)}),r?.managementHint?(0,L.jsx)(`p`,{className:`text-xs text-gray-500`,children:r.managementHint}):null,i&&!e?(0,L.jsx)(`p`,{className:`text-sm text-amber-700`,children:i}):null]}),o?(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`)}),o.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:o.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)(m,{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)(u,{children:[(0,L.jsxs)(d,{children:[(0,L.jsx)(s,{children:t(`runtimePresenceTitle`)}),(0,L.jsx)(g,{children:t(`runtimePresenceDescription`)})]}),(0,L.jsx)(a,{children:n})]})}function X(){let e=p().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)(f,{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)(f,{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)(o,{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 ue(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 $(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 $(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)(u,{children:[(0,L.jsxs)(d,{children:[(0,L.jsx)(s,{children:e.label??t(`agentList`)}),(0,L.jsx)(g,{children:e.help??t(`agentListHelp`)})]}),(0,L.jsxs)(a,{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)(i,{value:n.id,onChange:t=>e.onUpdateAgent(r,{id:t.target.value}),placeholder:t(`agentIdPlaceholder`)}),(0,L.jsx)(i,{value:n.workspace??``,onChange:t=>e.onUpdateAgent(r,{workspace:t.target.value}),placeholder:t(`workspaceOverridePlaceholder`)}),(0,L.jsx)(i,{value:n.model??``,onChange:t=>e.onUpdateAgent(r,{model:t.target.value}),placeholder:t(`modelOverridePlaceholder`)}),(0,L.jsx)(i,{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)(i,{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)(i,{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)(f,{checked:!!n.default,onCheckedChange:t=>e.onSetDefaultAgent(r,t)}),(0,L.jsx)(`span`,{children:t(`defaultAgent`)})]}),(0,L.jsxs)(m,{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)(m,{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)(u,{children:[(0,L.jsxs)(d,{children:[(0,L.jsx)(s,{children:e.label??t(`bindings`)}),(0,L.jsx)(g,{children:e.help??t(`bindingsHelp`)})]}),(0,L.jsxs)(a,{className:`space-y-3`,children:[e.bindings.map((n,r)=>{let a=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)(i,{value:n.agentId,onChange:t=>e.onUpdateBinding(r,{...n,agentId:t.target.value}),placeholder:t(`targetAgentIdPlaceholder`)}),(0,L.jsx)(i,{value:n.match.channel,onChange:t=>e.onUpdateBinding(r,{...n,match:{...n.match,channel:t.target.value}}),placeholder:t(`channelPlaceholder`)}),(0,L.jsx)(i,{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:a||`__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)(i,{value:n.match.peer?.id??``,onChange:t=>e.onUpdateBinding(r,{...n,match:{...n.match,peer:a?{kind:a,id:t.target.value}:void 0}}),placeholder:t(`peerIdPlaceholder`)})]}),(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsxs)(m,{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)(m,{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)(u,{children:[(0,L.jsxs)(d,{children:[(0,L.jsx)(s,{children:e.label??`Runtime Entries`}),(0,L.jsx)(g,{children:e.help??`统一管理可见的 runtime entry 与其配置。`})]}),(0,L.jsxs)(a,{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)(i,{value:t.id,onChange:t=>e.onUpdateEntry(n,{id:t.target.value}),placeholder:`entry id,例如 hermes`}),(0,L.jsx)(i,{value:t.label??``,onChange:t=>e.onUpdateEntry(n,{label:t.target.value}),placeholder:`展示名称,例如 Hermes`}),(0,L.jsx)(i,{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)(f,{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)(m,{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)(m,{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)(u,{children:[(0,L.jsxs)(d,{children:[(0,L.jsx)(s,{children:e.dmScopeLabel??t(`dmScope`)}),(0,L.jsx)(g,{children:e.dmScopeHelp??t(`dmScopeHelp`)})]}),(0,L.jsxs)(a,{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)(f,{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)(i,{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)(i,{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)(()=>ue(e.config),[e.config]),[r,i]=(0,I.useState)(n.agents),[a,o]=(0,I.useState)(n.bindings),[s,u]=(0,I.useState)(n.runtimeEntries),[d,f]=(0,I.useState)(n.dmScope),[p,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)(l,{className:`space-y-6`,children:[(0,L.jsx)(ie,{}),(0,L.jsx)(ge,{companionEnabled:p,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:s,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)(m,{type:`button`,onClick:()=>{try{let t=de({companionEnabled:p,agents:r,bindings:a,runtimeEntries:s,dmScope:d,defaultContextTokens:g,defaultEngine:v,knownAgentIds:b});e.updateRuntime.mutate({data:t})}catch(e){c.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,Bt as r,F as i,Ft as a,G as o,H as s,I as c,It as l,J as u,K as d,L as f,Lt as p,M as m,N as h,P as g,Q as _,R as v,U as y,W as b,X as x,Y as S,Z as C,_ as w,f as T,g as E,h as D,m as O,p as k,q as A,v as j,z as ee}from"./api-BcqDx0tm.js";function M(){return p({queryKey:[`config`],queryFn:f,staleTime:3e4,refetchOnWindowFocus:!0})}function N(){return p({queryKey:[`app-meta`],queryFn:c,staleTime:1/0})}function P(){return p({queryKey:[`config-meta`],queryFn:v,staleTime:1/0})}function F(){return p({queryKey:[`config-schema`],queryFn:ee,staleTime:1/0})}function I(){let t=r();return l({mutationFn:S,onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),a.success(e(`configSaved`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function L(){let t=r();return l({mutationFn:({data:e})=>_(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function R(){let t=r();return l({mutationFn:({provider:e,data:t})=>x(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSaved`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function z(){let t=r();return l({mutationFn:({data:e})=>m(e??{}),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSaved`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function B(){let t=r();return l({mutationFn:({provider:e})=>g(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSaved`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function V(){return l({mutationFn:({provider:e,data:t})=>A(e,t)})}function H(){return l({mutationFn:({provider:e,data:t})=>d(e,t)})}function U(){return l({mutationFn:({provider:e,data:t})=>y(e,t)})}function W(){return l({mutationFn:({provider:e})=>s(e)})}function G(){let t=r();return l({mutationFn:({channel:e,data:t})=>u(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),t.invalidateQueries({queryKey:[`config-meta`]}),a.success(e(`configSavedApplying`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function K(){let t=r();return l({mutationFn:({data:e})=>C(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`config`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function q(){let n=r();return l({mutationFn:({data:e})=>t(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`config`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function J(){return l({mutationFn:({actionId:e,data:t})=>i(e,t),onError:t=>{a.error(e(`error`)+`: `+t.message)}})}function Y(e){return p({queryKey:[`ncp-sessions`,e?.limit??null],queryFn:()=>w(e),staleTime:5e3,retry:!1})}function X(e,t=200){return p({queryKey:[`ncp-session-messages`,e,t],queryFn:()=>D(e,t),enabled:!!e,staleTime:5e3,retry:!1})}function Z(e){return p({queryKey:[`ncp-session-skills`,e.sessionId,e.projectRoot??null],queryFn:()=>E(e.sessionId,{...Object.prototype.hasOwnProperty.call(e,`projectRoot`)?{projectRoot:e.projectRoot??null}:{}}),enabled:!!e.sessionId,staleTime:5e3,retry:!1})}function Q(){let t=r();return l({mutationFn:({sessionId:e})=>O(e),onSuccess:(n,r)=>{T(t,r.sessionId),t.removeQueries({queryKey:[`ncp-session-messages`,r.sessionId]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function $(){let t=r();return l({mutationFn:({sessionId:e,data:t})=>j(e,t),onSuccess:n=>{k(t,n),t.invalidateQueries({queryKey:[`ncp-session-skills`,n.sessionId]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function te(e={all:!0}){return p({queryKey:[`cron`,e],queryFn:()=>n(e),staleTime:1e4})}function ne(){let t=r();return l({mutationFn:({id:e})=>h(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function re(){let t=r();return l({mutationFn:({id:e,enabled:t})=>o(e,{enabled:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.error(e(`configSaveFailed`)+`: `+t.message)}})}function ie(){let t=r();return l({mutationFn:({id:e,force:t})=>b(e,{force:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`cron`]}),a.success(e(`configSavedApplied`))},onError:t=>{a.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,M 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,105 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { applyNcpSessionRealtimeEvent, nextclawClient } from '@/shared/lib/api';
|
|
3
|
-
import { systemStatusManager } from '@/features/system-status';
|
|
4
|
-
import type { QueryClient } from '@tanstack/react-query';
|
|
5
|
-
import type { NextClawRealtimeEvent } from '@nextclaw/client-sdk';
|
|
6
|
-
|
|
7
|
-
function shouldInvalidateConfigQuery(configPath: string) {
|
|
8
|
-
const normalized = configPath.trim().toLowerCase();
|
|
9
|
-
if (!normalized) {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
|
-
if (normalized.startsWith('plugins') || normalized.startsWith('skills')) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function invalidateMarketplaceQueries(queryClient: QueryClient | undefined, configPath: string): void {
|
|
19
|
-
if (configPath.startsWith('plugins')) {
|
|
20
|
-
queryClient?.invalidateQueries({ queryKey: ['ncp-session-types'] });
|
|
21
|
-
queryClient?.invalidateQueries({ queryKey: ['marketplace-installed', 'plugin'] });
|
|
22
|
-
queryClient?.invalidateQueries({ queryKey: ['marketplace-items'] });
|
|
23
|
-
}
|
|
24
|
-
if (configPath.startsWith('mcp')) {
|
|
25
|
-
queryClient?.invalidateQueries({ queryKey: ['marketplace-mcp-installed'] });
|
|
26
|
-
queryClient?.invalidateQueries({ queryKey: ['marketplace-mcp-items'] });
|
|
27
|
-
queryClient?.invalidateQueries({ queryKey: ['marketplace-mcp-doctor'] });
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function handleConfigUpdatedEvent(queryClient: QueryClient | undefined, path: string): void {
|
|
32
|
-
if (queryClient && shouldInvalidateConfigQuery(path)) {
|
|
33
|
-
queryClient.invalidateQueries({ queryKey: ['config'] });
|
|
34
|
-
}
|
|
35
|
-
invalidateMarketplaceQueries(queryClient, path);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function handleRealtimeEvent(
|
|
39
|
-
params: {
|
|
40
|
-
queryClient: QueryClient | undefined;
|
|
41
|
-
shouldResyncSessions: boolean;
|
|
42
|
-
clearShouldResyncSessions: () => void;
|
|
43
|
-
markShouldResyncSessions: () => void;
|
|
44
|
-
event: NextClawRealtimeEvent;
|
|
45
|
-
}
|
|
46
|
-
): void {
|
|
47
|
-
const {
|
|
48
|
-
queryClient,
|
|
49
|
-
shouldResyncSessions,
|
|
50
|
-
clearShouldResyncSessions,
|
|
51
|
-
markShouldResyncSessions,
|
|
52
|
-
event,
|
|
53
|
-
} = params;
|
|
54
|
-
if (event.type === 'connection.open') {
|
|
55
|
-
systemStatusManager.handleConnectionRestored();
|
|
56
|
-
if (shouldResyncSessions) {
|
|
57
|
-
clearShouldResyncSessions();
|
|
58
|
-
queryClient?.invalidateQueries({ queryKey: ['ncp-sessions'] });
|
|
59
|
-
}
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (event.type === 'connection.close' || event.type === 'connection.error') {
|
|
63
|
-
systemStatusManager.handleConnectionInterrupted(
|
|
64
|
-
event.type === 'connection.error' ? event.payload?.message : null
|
|
65
|
-
);
|
|
66
|
-
markShouldResyncSessions();
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (event.type === 'config.updated') {
|
|
70
|
-
const configPath = typeof event.payload?.path === 'string' ? event.payload.path : '';
|
|
71
|
-
handleConfigUpdatedEvent(queryClient, configPath);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (
|
|
75
|
-
event.type === 'session.run-status' ||
|
|
76
|
-
event.type === 'session.summary.upsert' ||
|
|
77
|
-
event.type === 'session.summary.delete'
|
|
78
|
-
) {
|
|
79
|
-
applyNcpSessionRealtimeEvent(queryClient, event);
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (event.type === 'error') {
|
|
83
|
-
console.error('Realtime transport error:', event.payload.message);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function useRealtimeQueryBridge(queryClient?: QueryClient) {
|
|
88
|
-
const shouldResyncSessionsRef = useRef(false);
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
return nextclawClient.realtime.subscribe((event) =>
|
|
92
|
-
handleRealtimeEvent({
|
|
93
|
-
queryClient,
|
|
94
|
-
shouldResyncSessions: shouldResyncSessionsRef.current,
|
|
95
|
-
clearShouldResyncSessions: () => {
|
|
96
|
-
shouldResyncSessionsRef.current = false;
|
|
97
|
-
},
|
|
98
|
-
markShouldResyncSessions: () => {
|
|
99
|
-
shouldResyncSessionsRef.current = true;
|
|
100
|
-
},
|
|
101
|
-
event,
|
|
102
|
-
})
|
|
103
|
-
).close;
|
|
104
|
-
}, [queryClient]);
|
|
105
|
-
}
|