@xopcai/xopc 0.0.393 → 0.0.395
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-1AF2KGju.js → agent-avatar-dicebear-BRtkz-ZU.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-Dqg2NOn-.js +1 -0
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-cjJXJj_3.js → agent-plugin-dialog-CKK95Jmr.js} +1 -1
- package/dist/gateway/static/root/assets/agents-0zgLsfVA.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-B5aykqg_.js → agents-admin-api-BjGOUrAf.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B_MFhXXU.js → app-management-settings-panel-BZS8FvoL.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-TYGidVnd.js → appearance-settings-RxXMAxiB.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-mGU9WLjP.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BrFfEp0u.js → archive-plugin-DEnHq3OR.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-B7OofUPF.js → automations-page-BwkugzB8.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-K8aDhoYt.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BfAWnYG8.js → binary-plugins-NWeXhh1k.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-_Y-QwZ-3.js → block-editor-D_bKN3BN.js} +3 -3
- package/dist/gateway/static/root/assets/{browser-automation-inputs-DH9QHI9m.js → browser-automation-inputs-vtPkXfJ8.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-DBPbwOG8.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-VBZDYoXD.js +3 -0
- package/dist/gateway/static/root/assets/{capabilities-pt2M56-E.js → capabilities-CTfLd_UE.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-CQsGp9Sx.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C_OMsW_8.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-CFVx3iaZ.js → capability-header-actions-CMJXWq8a.js} +1 -1
- package/dist/gateway/static/root/assets/channels-C_TVCc1N.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-D3GuiG3N.js → chat-terminal-dock-9YRAokOl.js} +16 -16
- package/dist/gateway/static/root/assets/computer-settings-page-BPYAZ4ks.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-CDyCHkpK.js → connector-service-page-B81cEAEX.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-C0NvAP2V.js +1 -0
- package/dist/gateway/static/root/assets/date-picker-BvKP4P3n.js +1 -0
- package/dist/gateway/static/root/assets/{dependency-picker-BVJh9sYc.js → dependency-picker-TvrNaf8y.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Q52A8vjp.js → desktop-pet-De-_QNSD.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CZr1CXxu.js → desktop-pet-settings-CRSRTIwT.js} +1 -1
- package/dist/gateway/static/root/assets/{device-pairing-wizard-D_WWTsze.js → device-pairing-wizard-DnyJ8Bja.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-C6cUgrvg.js → directory-picker-path-field-DOPXwYNR.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DyyfC4gA.js → extension-debug-page-DzXvpUwj.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Dho9o3ZZ.js → extension-page-C0S1zNeP.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CdnIGyCH.js → extension-settings-page-C3Z7bFjy.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BEePO3Wl.js → gateway-config-swr-Di9g6pE8.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-Dng_VOvI.js → gateway-realtime-2-o7qk92.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-DQ6-whg-.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-Btc2wTQe.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CDCiy7Cd.js → gateway-startup-retry-BCUswcVy.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BNpj_mIM.js → highlighted-body-KQOG7T2V-BFYBbh1P.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-C5sLR47Q.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-DwkO2y46.js → image-generation-api-Vqcyqnzb.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BrYvomnU.js → imports-page-BJGHrzhX.js} +1 -1
- package/dist/gateway/static/root/assets/index-BNRLzxpH.js +260 -0
- package/dist/gateway/static/root/assets/index-zIgp-ZTu.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BveDYfYk.js → keyboard-shortcuts-settings-BQkQoPmm.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DbxLz9Ms.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-B1a69mlV.js → local-apps-page-CaatwSrK.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-CYEDUPH7.js → local-session-drafts-BjwlkAKA.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CE7L6MlS.js → locale-store-Djl2FW6_.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-3Wo4Lmts.js +2 -0
- package/dist/gateway/static/root/assets/management-settings-BHlbM8IM.js +1 -0
- package/dist/gateway/static/root/assets/{markdown-view-PrKvVpRh.js → markdown-view-DyO7Q0Ms.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CR1fp6IL.js → media-plugins-Cq1uLrd8.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-XhlIBp5t.js +1 -0
- package/dist/gateway/static/root/assets/{messages-CaeL_miw.js → messages-DPxcWxfD.js} +2 -2
- package/dist/gateway/static/root/assets/note-detail-panel-MjKND8HC.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-Cv040hVD.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-Cn_WK68Y.js → page-context-capture-button-Cp71nTq2.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-CyEUWV2n.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-3NbiWGRG.js → preview-open-alternatives-gzCecXc4.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-KKE5-V8k.js → product-open-page-CWFT7VuQ.js} +1 -1
- package/dist/gateway/static/root/assets/product-preview-content-Dh111Kca.js +1 -0
- package/dist/gateway/static/root/assets/project-detail-page-CyhyZiTi.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-QUdyJino.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BO2Ck3aA.js → registry-api-BwR2CiR5.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Cd8P0Dxs.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-B1sb8nlw.js → runtime-tools-api-C_VOMhLI.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-W0X_Fy7b.js → runtime-tools-settings-panel-bTjVfYm5.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DNM2Zdyr.js → schema-form-BGOzfVyj.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-CaAUJvu1.js → session-api-DbNNQps9.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-DoFTlgNz.js → session-manager-DfVviLTK.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BGMemJF6.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BiySFw1N.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-DCSHPFAN.js → settings-form-section-Bqm1IKvR.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B18UbbaJ.js → settings-page-CniJVL-o.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-JPs4-QRw.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BLnS3hoH.js → share-preview-page-BnDGFgBR.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Cgp5BuLt.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-CcYGkRPL.js → skill-api-CFdrz6tl.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Cy5jVfms.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CxaA3P5E.js +2 -0
- package/dist/gateway/static/root/assets/sliding-indicator-hwz0sx3h.js +1 -0
- package/dist/gateway/static/root/assets/{style-BQqU-1pP.js → style-C_MAnir7.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-C974myUM.js → system-settings-panel-BjnIlilP.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-Bg79rPnF.js +2 -0
- package/dist/gateway/static/root/assets/{task-expandable-content-DTEVoNrM.js → task-expandable-content-D3i_51Oc.js} +1 -1
- package/dist/gateway/static/root/assets/tracing-settings-page-BCI0tUbe.js +1 -0
- package/dist/gateway/static/root/assets/{tunnel-api-DWyI3uA3.js → tunnel-api-0knnta9z.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-D5aT1eie.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-CY0YuljR.js → use-autosave-Ds_mbAfe.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-D7L0-pDt.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-BNG4ixJE.js → voice-api-key-field-CPoGdarN.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-D0Wscn9W.js → voice-config-api-Ceo_hqZC.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-CohIoAre.js → work-discovery-overlay-CWNguy2Z.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BcDMFfkT.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-BwZB-s4N.js +6 -0
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-C_COnY_B.js → xopc-cloud-account-card-DlKr98VO.js} +1 -1
- package/dist/gateway/static/root/index.html +16 -15
- package/dist/package.js +1 -1
- package/dist/src/agent/coding/run-verification.js +4 -4
- package/dist/src/agent/embedded/agent-profile-context.js +10 -4
- package/dist/src/agent/tools/exec-command.d.ts +2 -0
- package/dist/src/agent/tools/exec-command.js +45 -1
- package/dist/src/config/models-json.d.ts +16 -16
- package/dist/src/providers/cloud-thinking.d.ts +3 -0
- package/dist/src/providers/cloud-thinking.js +13 -0
- package/dist/src/providers/model-registry.js +3 -0
- package/dist/src/providers/register-runtime-providers.js +3 -0
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CPJr7NRR.js +0 -1
- package/dist/gateway/static/root/assets/agents-DW3TlnIg.js +0 -77
- package/dist/gateway/static/root/assets/apps-page-DOkyvOF0.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-DIod-bfm.js +0 -6
- package/dist/gateway/static/root/assets/browser-automations-page-B_SnD9B0.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-BPlqYpMM.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-page-BtzZvMIK.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-WzoG3oBb.js +0 -8
- package/dist/gateway/static/root/assets/channels-BXA55GY2.js +0 -1
- package/dist/gateway/static/root/assets/computer-settings-page-CIbHDlp8.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DA2b6cJu.js +0 -1
- package/dist/gateway/static/root/assets/date-picker-C424c_g9.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-DtlBf7oH.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-D0KSQRNZ.js +0 -1
- package/dist/gateway/static/root/assets/home-page-CH_A0W29.js +0 -2
- package/dist/gateway/static/root/assets/index-CKdOZoVu.js +0 -260
- package/dist/gateway/static/root/assets/index-Rxjt-jc3.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CcIi1BhT.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-Us1jv3C4.js +0 -2
- package/dist/gateway/static/root/assets/management-settings-C9RAM7-s.js +0 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DQdcaMiu.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-Q4yRx9iZ.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-C9qu16IN.js +0 -8
- package/dist/gateway/static/root/assets/personal-page-DrP6hEcg.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-content-BM0oqNxi.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-CPZrwf8n.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-Besfx_07.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CTDghL5L.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-Dxtablvd.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-C7zklouD.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-JoSfluza.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DcIuPJK3.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-PnUZjoPK.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-D3JAw62U.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-CiljFekC.js +0 -2
- package/dist/gateway/static/root/assets/tracing-settings-page-DEE75MUn.js +0 -1
- package/dist/gateway/static/root/assets/usage-page-DJYvbxk7.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-eHZJD6Fw.js +0 -2
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BXI8eyYh.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-CVti0u-l.js +0 -6
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./ellipsis-0k4rZLoy.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./eye-CABVeTq0.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-CaeL_miw.js";import{t as p}from"./cn-0WouolD0.js";import{a as m,c as h,n as g,r as _}from"./locale-store-CE7L6MlS.js";import{a as v,i as y,n as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{n as T}from"./copy-to-clipboard-HOJ79TWv.js";import{n as E,r as D}from"./gateway-config-swr-BEePO3Wl.js";import{$ as O,$n as k,Ac as A,Cc as j,Dc as M,Ec as N,Fl as P,Hc as F,Hu as I,Ic as L,Id as R,Is as z,J as B,Jd as V,Jn as H,Kd as U,Lo as W,Mc as G,Nd as ee,Oc as te,Ol as ne,Pc as K,Q as q,Ql as re,Sc as ie,Tc as ae,Tu as oe,Uo as J,X as se,Xa as ce,Xl as le,Xn as ue,Y,Yn as X,Z,_c as de,_l as fe,ac as pe,ad as me,af as he,au as ge,bc as _e,cc as ve,cs as ye,dc as be,ec as xe,er as Se,et as Ce,fc as we,gc as Te,hc as Ee,ic as De,if as Oe,ir as ke,is as Ae,jc as je,kc as Me,lc as Ne,ls as Pe,mc as Fe,nc as Ie,nr as Le,ns as Re,nu as ze,oc as Be,pc as Ve,qn as He,rc as Ue,sc as We,sf as Ge,tc as Ke,tr as qe,us as Je,wc as Ye,yc as Xe}from"./index-CKdOZoVu.js";import{n as Ze,t as Qe}from"./capability-header-actions-CFVx3iaZ.js";import{t as $e}from"./connector-service-page-CDyCHkpK.js";import{n as et}from"./agent-plugin-dialog-cjJXJj_3.js";import{t as tt}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),nt=n(),$=r();function rt(e){let t=(0,nt.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:s}=e,c,l,u,d,f,m;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==s){let e=n.capabilities.filter(it),h=e.slice(0,2),g=Math.max(0,e.length-h.length),_=s.connect,v;t[11]!==n||t[12]!==s?(v=Z(n,s),t[11]=n,t[12]=s,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?s.connectorVerified:n.verificationLevel===`beta`?s.connectorBeta:n.verificationLevel===`experimental`?s.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(F,{type:`button`,variant:`primary`,className:p(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(oe,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],c=x,m=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,l=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(Ce,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==c?(D=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:c()}),t[31]=r,t[32]=c,t[33]=D):D=t[33];let O;t[34]!==r||t[35]!==s.connectedBadge?(O=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(o,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[34]=r,t[35]=s.connectedBadge,t[36]=O):O=t[36];let k;t[37]!==D||t[38]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=k):k=t[39],t[40]!==E||t[41]!==k?(u=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,k]}),t[40]=E,t[41]=k,t[42]=u):u=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),f=h.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[h.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:s.connectorCapabilityLabels[e]??e},e)),g>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,g]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=m}else c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],m=t[10];let h;t[45]!==l||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,$.jsxs)(`div`,{className:l,children:[u,d,f]}),t[45]=l,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]!==r||t[51]!==c?(g=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[50]=r,t[51]=c,t[52]=g):g=t[52];let _;return t[53]!==m||t[54]!==h||t[55]!==g?(_=(0,$.jsxs)(`div`,{className:m,children:[h,g]}),t[53]=m,t[54]=h,t[55]=g,t[56]=_):_=t[56],_}function it(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var at=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function ot(e,t){return t.some(t=>t.connectorId===e.id)}var st=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ct(){let e=(0,nt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,st)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:p(`h-4 min-w-0 flex-1`,st)}),(0,$.jsx)(`div`,{className:p(`h-8 w-[4.5rem] shrink-0 rounded-lg`,st)})]}),(0,$.jsx)(`div`,{className:p(`h-3 w-full`,st)}),(0,$.jsx)(`div`,{className:p(`h-3 w-[88%]`,st)})]})]})}),e[1]=n):n=e[1],n}var lt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ut(){let e=(0,nt.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,lt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:p(`h-4 w-48 max-w-full`,lt)}),(0,$.jsx)(`div`,{className:p(`h-3 w-72 max-w-full`,lt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:p(`h-9 w-20 rounded-lg`,lt)}),(0,$.jsx)(`div`,{className:p(`h-9 w-20 rounded-lg`,lt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:p(`h-8 w-20 rounded-md`,lt)}),(0,$.jsx)(`div`,{className:p(`h-8 w-24 rounded-md`,lt)}),(0,$.jsx)(`div`,{className:p(`h-8 w-28 rounded-md`,lt)})]}),(0,$.jsx)(`div`,{className:p(`mt-3 h-20 rounded-xl`,lt)})]}),e[3]=i):i=e[3],i}var dt=[`understand`,`act`,`reach`];function ft(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function pt(e){return ft(e)[0]??`act`}function mt(e,t){let n=t?pt(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function ht(e,t){return t.connectorCapabilityLabels[e]??e}function gt(e,t){if(e.runtime.type===`mcp`)return q(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return q(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function _t(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function vt(e){let t=(0,nt.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:s}=e,c;t[0]!==n||t[1]!==s?(c=Z(n,s),t[0]=n,t[1]=s,t[2]=c):c=t[2];let l=c,u,f,m,h,g,_,T,E,D,O,k,A,j,M,N,P;if(t[3]!==n||t[4]!==l||t[5]!==r||t[6]!==i||t[7]!==s){let e=ft(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(xt),...(n.setup.config??[]).filter(bt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let c=a,F=n.capabilities.filter(yt);m=w,T=!0,t[27]===i?E=t[28]:(E=e=>{e||i()},t[27]=i,t[28]=E),f=x,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=_):_=t[29],u=S,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(h=p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=h):h=t[30];let I;t[31]===n?I=t[32]:(I=(0,$.jsx)(Ce,{connector:n,size:`lg`}),t[31]=n,t[32]=I);let L;t[33]===n.displayName?L=t[34]:(L=(0,$.jsx)(C,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=L);let R;t[35]!==r||t[36]!==s.connectedBadge?(R=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(o,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[35]=r,t[36]=s.connectedBadge,t[37]=R):R=t[37];let z;t[38]!==L||t[39]!==R?(z=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[L,R]}),t[38]=L,t[39]=R,t[40]=z):z=t[40];let B;t[41]===l?B=t[42]:(B=(0,$.jsx)(y,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:l}),t[41]=l,t[42]=B);let V;t[43]!==z||t[44]!==B?(V=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[z,B]}),t[43]=z,t[44]=B,t[45]=V):V=t[45];let H;t[46]!==I||t[47]!==V?(H=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[I,V]}),t[46]=I,t[47]=V,t[48]=H):H=t[48];let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,K.focusRingPanel),t[49]=U):U=t[49];let W;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(d,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=W):W=t[50];let G;t[51]===s.modalClose?G=t[52]:(G=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:U,"aria-label":s.modalClose,children:W})}),t[51]=s.modalClose,t[52]=G),t[53]!==H||t[54]!==G?(g=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[H,G]}),t[53]=H,t[54]=G,t[55]=g):g=t[55],M=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,N=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.connectorBenefitHints[e]})]},e))})]}):null;let ee;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(me,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=ee):ee=t[56];let te;t[57]===s.detailPermissions?te=t[58]:(te=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.detailPermissions}),t[57]=s.detailPermissions,t[58]=te);let ne;t[59]!==n||t[60]!==s?(ne=_t(n,s),t[59]=n,t[60]=s,t[61]=ne):ne=t[61];let ie;t[62]===ne?ie=t[63]:(ie=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:ne}),t[62]=ne,t[63]=ie);let ae;t[64]!==te||t[65]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[ee,(0,$.jsxs)(`div`,{children:[te,ie]})]}),t[64]=te,t[65]=ie,t[66]=ae):ae=t[66];let oe;t[67]===s.connectorSetupTitle?oe=t[68]:(oe=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.connectorSetupTitle}),t[67]=s.connectorSetupTitle,t[68]=oe);let J;t[69]!==c.length||t[70]!==s.connectorRequiredInputsCount||t[71]!==s.connectorSetupNone?(J=c.length?q(s.connectorRequiredInputsCount,{count:String(c.length)}):s.connectorSetupNone,t[69]=c.length,t[70]=s.connectorRequiredInputsCount,t[71]=s.connectorSetupNone,t[72]=J):J=t[72];let se;t[73]===J?se=t[74]:(se=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:J}),t[73]=J,t[74]=se);let ce;t[75]!==oe||t[76]!==se?(ce=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[oe,se]}),t[75]=oe,t[76]=se,t[77]=ce):ce=t[77],t[78]!==ae||t[79]!==ce?(P=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[ae,ce]}),t[78]=ae,t[79]=ce,t[80]=P):P=t[80],A=`rounded-xl border border-edge bg-surface-base`,t[81]===s.connectorTechnicalDetails?j=t[82]:(j=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:s.connectorTechnicalDetails}),t[81]=s.connectorTechnicalDetails,t[82]=j),D=`space-y-5 border-t border-edge-subtle px-4 py-4`;let le;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),t[83]=le):le=t[83];let ue;t[84]===s.connectorRuntimeTitle?ue=t[85]:(ue=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[le,s.connectorRuntimeTitle]}),t[84]=s.connectorRuntimeTitle,t[85]=ue);let Y;t[86]!==n||t[87]!==s?(Y=gt(n,s),t[86]=n,t[87]=s,t[88]=Y):Y=t[88];let X;t[89]===Y?X=t[90]:(X=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:Y}),t[89]=Y,t[90]=X),t[91]!==ue||t[92]!==X?(O=(0,$.jsxs)(`div`,{children:[ue,X]}),t[91]=ue,t[92]=X,t[93]=O):O=t[93],k=F.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:F.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:ht(e,s)},e))}):null,t[3]=n,t[4]=l,t[5]=r,t[6]=i,t[7]=s,t[8]=u,t[9]=f,t[10]=m,t[11]=h,t[12]=g,t[13]=_,t[14]=T,t[15]=E,t[16]=D,t[17]=O,t[18]=k,t[19]=A,t[20]=j,t[21]=M,t[22]=N,t[23]=P}else u=t[8],f=t[9],m=t[10],h=t[11],g=t[12],_=t[13],T=t[14],E=t[15],D=t[16],O=t[17],k=t[18],A=t[19],j=t[20],M=t[21],N=t[22],P=t[23];let I;t[94]!==D||t[95]!==O||t[96]!==k?(I=(0,$.jsxs)(`div`,{className:D,children:[O,k]}),t[94]=D,t[95]=O,t[96]=k,t[97]=I):I=t[97];let L;t[98]!==I||t[99]!==A||t[100]!==j?(L=(0,$.jsxs)(`details`,{className:A,children:[j,I]}),t[98]=I,t[99]=A,t[100]=j,t[101]=L):L=t[101];let R;t[102]!==L||t[103]!==M||t[104]!==N||t[105]!==P?(R=(0,$.jsxs)(`div`,{className:M,children:[N,P,L]}),t[102]=L,t[103]=M,t[104]=N,t[105]=P,t[106]=R):R=t[106];let z;t[107]===s.modalClose?z=t[108]:(z=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(F,{variant:`secondary`,children:s.modalClose})}),t[107]=s.modalClose,t[108]=z);let B;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==s.connect?(B=r?null:(0,$.jsxs)(F,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(oe,{className:`size-4`}),s.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=s.connect,t[114]=B):B=t[114];let V;t[115]!==z||t[116]!==B?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[z,B]}),t[115]=z,t[116]=B,t[117]=V):V=t[117];let H;t[118]!==u||t[119]!==h||t[120]!==g||t[121]!==R||t[122]!==V?(H=(0,$.jsxs)(u,{className:h,children:[g,R,V]}),t[118]=u,t[119]=h,t[120]=g,t[121]=R,t[122]=V,t[123]=H):H=t[123];let U;t[124]!==f||t[125]!==_||t[126]!==H?(U=(0,$.jsxs)(f,{children:[_,H]}),t[124]=f,t[125]=_,t[126]=H,t[127]=U):U=t[127];let W;return t[128]!==m||t[129]!==T||t[130]!==E||t[131]!==U?(W=(0,$.jsx)(m,{open:T,onOpenChange:E,children:U}),t[128]=m,t[129]=T,t[130]=E,t[131]=U,t[132]=W):W=t[132],W}function yt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function bt(e){return e.required}function xt(e){return e.required}var St=(0,Q.memo)(function(e){let t=(0,nt.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:c,browseLabel:l,customLabel:d,serviceLabel:f,moreActionsLabel:m}=e,[h,g]=(0,Q.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=p(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,K.transition),t[0]=_):_=t[0];let v=_,y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(u,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=y):y=t[1];let b;t[2]===c?b=t[3]:(b=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:c}),t[2]=c,t[3]=b);let x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Ge,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=x):x=t[4];let S;t[5]!==c||t[6]!==b?(S=(0,$.jsx)(ke,{asChild:!0,children:(0,$.jsxs)(F,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":c,children:[y,b,x]})}),t[5]=c,t[6]=b,t[7]=S):S=t[7];let C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(P,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=C):C=t[8];let w;t[9]!==l||t[10]!==a?(w=(0,$.jsxs)(Se,{className:v,onSelect:a,children:[C,l]}),t[9]=l,t[10]=a,t[11]=w):w=t[11];let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(fe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=T):T=t[12];let E;t[13]!==d||t[14]!==o?(E=(0,$.jsxs)(Se,{className:v,onSelect:o,children:[T,d]}),t[13]=d,t[14]=o,t[15]=E):E=t[15];let D;t[16]!==w||t[17]!==E?(D=(0,$.jsx)(qe,{children:(0,$.jsxs)(k,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[w,E]})}),t[16]=w,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==D||t[20]!==S?(O=(0,$.jsxs)(Le,{children:[S,D]}),t[19]=D,t[20]=S,t[21]=O):O=t[21];let A;t[22]===h?A=t[23]:(A=(0,$.jsx)($e,{open:h,onOpenChange:g,hideTrigger:!0}),t[22]=h,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[24]=j):j=t[24];let M;t[25]===m?M=t[26]:(M=(0,$.jsx)(ke,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":m,title:m,children:j})}),t[25]=m,t[26]=M);let N;t[27]!==n||t[28]!==i||t[29]!==r?(N=n?(0,$.jsxs)(Se,{className:v,disabled:r,onSelect:n,children:[r?(0,$.jsx)(I,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(ge,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=N):N=t[30];let L,R;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>g(!0),R=(0,$.jsx)(le,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=L,t[32]=R):(L=t[31],R=t[32]);let z;t[33]===f?z=t[34]:(z=(0,$.jsxs)(Se,{className:v,onSelect:L,children:[R,f]}),t[33]=f,t[34]=z);let B;t[35]!==N||t[36]!==z?(B=(0,$.jsx)(qe,{children:(0,$.jsxs)(k,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[N,z]})}),t[35]=N,t[36]=z,t[37]=B):B=t[37];let V;t[38]!==M||t[39]!==B?(V=(0,$.jsxs)(Le,{children:[M,B]}),t[38]=M,t[39]=B,t[40]=V):V=t[40];let H;return t[41]!==O||t[42]!==A||t[43]!==V?(H=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[O,A,V]}),t[41]=O,t[42]=A,t[43]=V,t[44]=H):H=t[44],H});function Ct(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var wt=/^([^:=]+)[:=](.*)$/;function Tt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Dt(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=wt.exec(t);r&&n.push(Ct(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Et(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function Dt(e){if(!e||typeof e!=`object`)return[Ct()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Ct(e),reference:t}:Ct(e,t==null?``:String(t)));return t.length>0?t:[Ct()]}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function kt(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function At(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function jt(e){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=kt(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=Et(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=At(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Et(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Mt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:Dt(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Nt(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Pt(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Ft(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Mt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Pt(r.url),r})}function It(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Lt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Ot(e)).map(([e,t])=>Mt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function Rt(e){return jt(e)}async function zt(e,t){return(await m(_(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Bt(e,t,n,r){return(await m(_(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:jt(e)})})).payload}async function Vt(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Ht(e){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Ut(e,t=!1){let n=await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return E(),n.payload}async function Wt(e){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function Gt(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function Kt(e){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function qt(e,t){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function Jt(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function Yt(e){let t=await m(_(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function Xt(e){let t=await m(_(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return E(),t.payload}function Zt(e){let t=(0,nt.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(O=()=>{let e=new AbortController,t=!0;return p(!0),h(``),d([]),(a?Jt(a,e.signal):zt(n,e.signal)).then(e=>{t&&d(e)}).catch(e=>{let n=e?.status;t&&h(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&p(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=O):O=t[8];let k;t[9]!==a||t[10]!==T||t[11]!==n||t[12]!==o?(k=[n,a,T,o],t[9]=a,t[10]=T,t[11]=n,t[12]=o,t[13]=k):k=t[13],(0,Q.useEffect)(O,k);let A,j,M,N,P,I,L,R,z,B,V,H,U;if(t[14]!==r||t[15]!==m||t[16]!==f||t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=g.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,d=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));M=w,I=!0,t[52]===s?L=t[53]:(L=e=>{e||s()},t[52]=s,t[53]=L),j=x,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(v,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=P):P=t[54],A=S,t[55]===i?H=t[56]:(H=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=H),U=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let p;t[57]===o.toolsDialogTitle?p=t[58]:(p=(0,$.jsx)(C,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=p);let h;t[59]!==r||t[60]!==m||t[61]!==f||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(h=f||m?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=m,t[61]=f,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=h):h=t[65];let b;t[66]===h?b=t[67]:(b=(0,$.jsx)(y,{className:`mt-1 break-words text-sm text-fg-muted`,children:h}),t[66]=h,t[67]=b);let T;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>_(e.target.value),t[68]=T):T=t[68];let E;t[69]!==g||t[70]!==o.toolsDialogSearchPlaceholder?(E=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:g,onChange:T,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=g,t[70]=o.toolsDialogSearchPlaceholder,t[71]=E):E=t[71];let O=e&&!f&&!m?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(d.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==p||t[73]!==b||t[74]!==E||t[75]!==O?(N=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[p,b,E,O]}),t[72]=p,t[73]=b,t[74]=E,t[75]=O,t[76]=N):N=t[76],R=`min-h-0 flex-1 overflow-y-auto p-5`,z=f,t[77]!==o.toolsTitle||t[78]!==u.length?(B=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=B):B=t[79],V=f?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map($t)}):m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:m}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(F,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):d.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[e.exposure]}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(F,{variant:`secondary`,onClick:()=>_(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=m,t[16]=f,t[17]=s,t[18]=c,t[19]=g,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=A,t[37]=j,t[38]=M,t[39]=N,t[40]=P,t[41]=I,t[42]=L,t[43]=R,t[44]=z,t[45]=B,t[46]=V,t[47]=H,t[48]=U}else A=t[36],j=t[37],M=t[38],N=t[39],P=t[40],I=t[41],L=t[42],R=t[43],z=t[44],B=t[45],V=t[46],H=t[47],U=t[48];let W;t[80]!==R||t[81]!==z||t[82]!==B||t[83]!==V?(W=(0,$.jsx)(`div`,{className:R,"aria-busy":z,"aria-label":B,children:V}),t[80]=R,t[81]=z,t[82]=B,t[83]=V,t[84]=W):W=t[84];let G;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(G=()=>E(Qt),t[85]=G):G=t[85];let ee;t[86]!==f||t[87]!==o.refreshTools?(ee=(0,$.jsx)(F,{variant:`secondary`,disabled:f,onClick:G,children:o.refreshTools}),t[86]=f,t[87]=o.refreshTools,t[88]=ee):ee=t[88];let te;t[89]!==s||t[90]!==o.toolsDialogClose?(te=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(F,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=te):te=t[91];let ne;t[92]!==ee||t[93]!==te?(ne=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[ee,te]}),t[92]=ee,t[93]=te,t[94]=ne):ne=t[94];let K;t[95]!==A||t[96]!==N||t[97]!==W||t[98]!==ne||t[99]!==H||t[100]!==U?(K=(0,$.jsxs)(A,{onCloseAutoFocus:H,className:U,children:[N,W,ne]}),t[95]=A,t[96]=N,t[97]=W,t[98]=ne,t[99]=H,t[100]=U,t[101]=K):K=t[101];let q;t[102]!==j||t[103]!==P||t[104]!==K?(q=(0,$.jsxs)(j,{children:[P,K]}),t[102]=j,t[103]=P,t[104]=K,t[105]=q):q=t[105];let re;return t[106]!==M||t[107]!==I||t[108]!==L||t[109]!==q?(re=(0,$.jsx)(M,{open:I,onOpenChange:L,children:q}),t[106]=M,t[107]=I,t[108]=L,t[109]=q,t[110]=re):re=t[110],re}function Qt(e){return e+1}function $t(e){return(0,$.jsx)(L,{className:`h-24 w-full`},e)}function en(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function tn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``);return(0,$.jsxs)(`div`,{className:`px-4 py-3.5`,children:[(0,$.jsxs)(`button`,{className:`block w-full text-left`,onClick:i,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.displayName||e.id}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:en(e)})]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.extra.enabled===!1?n.setupDisabled:t?n.setupLastCheck.replace(`{{count}}`,String(t.toolCount)):n.setupUnverified}),t?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`time`,{dateTime:t.checkedAt,children:new Intl.DateTimeFormat(void 0,{dateStyle:`short`,timeStyle:`short`}).format(new Date(t.checkedAt))})}):null,d?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:d}):null,(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(F,{ref:c,variant:`secondary`,disabled:e.extra.enabled===!1,onClick:()=>s(!0),children:n.viewTools}),(0,$.jsx)(F,{variant:`ghost`,onClick:()=>u(!0),children:n.removeServer})]}),o?(0,$.jsx)(Zt,{serverId:e.id,displayName:e.displayName,returnFocusTo:c.current,t:n,onClose:()=>s(!1),onConfigure:()=>{s(!1),i()}}):null,(0,$.jsx)(ce,{open:l,title:r.removeConfirmTitle.replace(`{{name}}`,e.displayName||e.id),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>u(!1),onConfirm:()=>{u(!1),f(``),a().catch(()=>f(n.setupRemoveFailed))}})]})}function nn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function rn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?nn(t)-nn(e):e.isCurrentAuthorization?-1:1}function an(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(rn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>rn(e.primary,t.primary))}var on=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z);function sn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function cn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function ln(e,t,n){return e.status===`connected`?q(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function un(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function dn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function fn({instance:e,t,onChanged:n}){let r=sn(e),i=g(e=>e.language)===`zh`,[a,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)([]),[f,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)({}),[E,D]=(0,Q.useState)(`read`),[O,k]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(!1),[B,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[W,ee]=(0,Q.useState)(!1),[K,re]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(!1),J=(0,Q.useRef)(0),le=(0,Q.useRef)(0),ue=(0,Q.useMemo)(()=>an(a),[a]),Y=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),X=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;k(!0),P(null);let t=++J.current;try{let e=(await Promise.allSettled([Y(Ve()).then(e=>{t===J.current&&(s(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),ee(!0))}),Y(Ne(r)).then(e=>{t===J.current&&D(e)}),Y(ve(r)).then(e=>{t===J.current&&(m(e.policy),_(e.agents))})])).find(e=>e.status===`rejected`);t===J.current&&e?.status===`rejected`&&P(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===J.current&&k(!1)}},[e.materialized,r,Y]);(0,Q.useEffect)(()=>(X(),()=>{J.current++}),[X]);let Z=(0,Q.useCallback)(async()=>{if(!r)return;let e=++le.current;oe(!0),z(!1);let t=t=>n=>{e===le.current&&t(n)},n=await Promise.allSettled([Y(Fe(r)).then(t(l)),Y(Ee(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),Y(be(r)).then(t(x)),Y(We(r)).then(t(y))]);e===le.current&&(z(n.some(e=>e.status===`rejected`)),oe(!1))},[r,Y]);(0,Q.useEffect)(()=>(K&&Z(),()=>{le.current++}),[K,Z]),(0,Q.useEffect)(()=>{let e=!1,t=an(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return Y(Te()).then(t=>{e||C(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await Y(we(e.accountId))])).then(t=>{e||T(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,Y]);let fe=(0,Q.useCallback)(async i=>{if(!r)return;let a=Ae()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),k(!0),P(null);try{if(!Ae()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await Ye(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(Ae()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await G(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),X()])}catch(e){P(se(e,t))}finally{a?.close(),k(!1)}},[e.connectorId,X,n,t,r]),pe=(0,Q.useCallback)(async t=>{k(!0),P(null);try{await A(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),X()])}catch(e){P(e instanceof Error?e.message:String(e))}finally{k(!1)}},[e.config,e.instanceId,X,n]),he=async e=>{let t=Ae()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),P(null);try{let n=await Be(e.id);if(n.authorizationUrl)if(Ae())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await X()}catch(e){t?.close(),P(e instanceof Error?e.message:String(e))}},ye=(0,Q.useCallback)(async e=>{if(r){D(e),P(null);try{await ie(r,e)}catch(e){P(e instanceof Error?e.message:String(e)),await X()}}},[X,r]),Se=(0,Q.useCallback)(async e=>{if(r){P(null);try{m(await Me(r,e))}catch(e){P(e instanceof Error?e.message:String(e))}}},[r]),Ce=(0,Q.useCallback)(e=>{if(!f)return;let t=f.allowedAgentIds.includes(e);t&&f.allowedAgentIds.length===1||Se({allowedAgentIds:t?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e]})},[Se,f]),De=(0,Q.useCallback)(async e=>{k(!0),P(null);try{await e(),await X()}catch(e){P(e instanceof Error?e.message:String(e))}finally{k(!1)}},[X]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let ke=ue.filter(e=>e.primary.status===`active`).length,Ie=ke>0?t.composioAddAccount:t.composioConnectAccount,Le=W&&ke>0,Re=b?.requiresCustomAuthConfig===!0,ze=b?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:p(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Le?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Le?(0,$.jsx)(o,{className:`size-3.5`}):(0,$.jsx)(Oe,{className:`size-3.5`}),Le?t.connectionReady:W||N?t.connectionNeedsSetup:t.connectionChecking]}),W&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:q(t.composioAccountCount,{count:String(ue.length)})})]}),(0,$.jsxs)(F,{variant:`primary`,className:`shrink-0`,disabled:O,onClick:()=>void fe(),children:[O?(0,$.jsx)(I,{className:`size-4 animate-spin`}):(0,$.jsx)(me,{className:`size-4`}),Ie]})]}),N?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:N}),(0,$.jsx)(F,{variant:`secondary`,disabled:O,onClick:()=>void X(),children:t.composioRetry})]}):null,v&&!Le?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:ln(v,ke,t)}),v.recovery===`none`?null:(0,$.jsx)(F,{variant:`secondary`,disabled:O,onClick:()=>void(v.recovery===`retry`?X():fe()),children:v.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,Re&&ze.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,f?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(Pe,{value:E,onChange:e=>void ye(e.currentTarget.value),children:[(0,$.jsx)(Je,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(Je,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,$.jsx)(Je,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(Pe,{value:f.confirmationPolicy,onChange:e=>void Se({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(Je,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(Je,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(Je,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:f.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void Se({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),h.map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Ce(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:f.selectedAccountIds===null,disabled:O,onChange:e=>void Se({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&ue.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:O,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void Se({selectedAccountIds:t.currentTarget.checked?[...f.selectedAccountIds,e.accountId]:f.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),f.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),W&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:q(t.composioAccountCount,{count:String(ue.length)})})]}),(0,$.jsxs)(F,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:O,onClick:()=>void X(),children:[(0,$.jsx)(ge,{className:p(`size-3.5`,O&&`animate-spin`)}),t.refresh]})]}),ue.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:ue.map(e=>{let r=e.primary,a=S.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?w[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:p(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:un(r.status,t)}),a?(0,$.jsx)(`p`,{className:p(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:q(t.connectorLearningStatus,{status:dn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void he(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(F,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:O,onClick:()=>U(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:O,onClick:()=>void fe(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:O,onClick:()=>void De(()=>M(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(F,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:O,onClick:()=>void De(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await j(r.accountId),await n?.()}),children:[(0,$.jsx)(ge,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:O,checked:r.allowedAgentIds==null,onChange:e=>void De(()=>M(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&h.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:O,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;De(()=>M(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:O,onChange:e=>void De(()=>je(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(Pe,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:O,onChange:e=>void De(()=>je(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(Je,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(Je,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(Je,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(Je,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:p(on,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&De(()=>te(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(F,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:O,onClick:()=>V(e.id),children:(0,$.jsx)(ne,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(F,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:O,onClick:()=>void De(()=>de(r.id)),children:(0,$.jsx)(ge,{className:`size-4`})})})]})]})]},e.key)})}):O&&!W?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(L,{className:`h-16 w-full`}),(0,$.jsx)(L,{className:`h-16 w-full`})]}):W?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>re(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[ae?(0,$.jsx)(L,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,R?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(F,{variant:`ghost`,disabled:ae,onClick:()=>void Z(),children:t.composioRetry})]}):null,b?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Re?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(Pe,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:O,onChange:e=>void pe(e.currentTarget.value),children:[Re?null:(0,$.jsx)(Je,{value:``,children:t.composioAuthConfigManaged}),Re&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(Je,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,ze.map(e=>(0,$.jsxs)(Je,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:c.length?c.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[cn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:u.length?u.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(ce,{open:H!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=H;U(null),e&&De(()=>xe(e))},onCancel:()=>U(null)}),(0,$.jsx)(ce,{open:B!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=B;V(null),e&&De(()=>_e(e))},onCancel:()=>V(null)})]})}var pn=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z);function mn(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function hn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function gn({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,T]=(0,Q.useState)(()=>mn(t,e)),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),P=t?.setup.config??[],L=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&P.length>0&&(t?.setup.secrets??[]).length===0,z=e.materialized.type===`mcp`,B=e.materialized.type===`composio`,V=e.materialized.type===`memorySource`,H=t?Z(t,i):null,U=(0,Q.useCallback)(async()=>{k(!0),D(null);try{let t=await N(e.instanceId);M(t),t.ok||D(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(!1)}},[e.instanceId,r,i.healthStatusLabels]),W=(0,Q.useCallback)(async()=>{o(!0),D(null);try{await Xe(e.instanceId),await r(),n()}catch(e){D(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),G=(0,Q.useCallback)(async()=>{if(!(!t||!L)){u(!0),D(null);try{let n={};for(let e of t.setup.config??[]){let t=hn(e.type,_[e.key]??``);t!==void 0&&(n[e.key]=t)}await A(e.instanceId,{config:n}),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[_,t,e.instanceId,r,L]),ee=(0,Q.useCallback)(async()=>{m(!0),g(null),D(null);try{g((await ae(e.connectorId)).recordIds.length),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,$.jsxs)(w,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(x,{children:[(0,$.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(S,{className:p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,B?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(Ce,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(C,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(y,{className:`mt-1 text-sm text-fg-muted`,children:H??(e.materialized.type===`mcp`?q(i.mcpServerRuntime,{serverId:e.materialized.serverId}):q(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(b,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,K.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(d,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[E?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:E}):null,z?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:j?.ok?q(i.toolsAvailable,{count:String(j.toolCount)}):j?i.healthStatusLabels[j.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(F,{variant:`secondary`,"aria-busy":O,disabled:O||!e.enabled,onClick:()=>void U(),children:[O?(0,$.jsx)(I,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ge,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),L?P.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:pn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>T(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,B?(0,$.jsx)(fn,{instance:e,t:i,onChanged:r}):null,V?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),H?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:H}):null,h===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:q(i.connectedSourceSynced,{count:String(h)})})]}),(0,$.jsxs)(F,{disabled:f,onClick:()=>void ee(),children:[f?(0,$.jsx)(I,{className:`size-4 animate-spin`}):(0,$.jsx)(R,{className:`size-4`}),i.composioSyncNow]})]}),L?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:P.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:pn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>T(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!z&&!B&&!V?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(F,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(I,{className:`size-4 animate-spin`}):(0,$.jsx)(ne,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(F,{variant:`secondary`,onClick:n,children:i.modalClose}),(z||V)&&L?(0,$.jsxs)(F,{variant:`primary`,disabled:l,onClick:()=>void G(),children:[l?(0,$.jsx)(I,{className:`size-4 animate-spin`}):(0,$.jsx)(ze,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(ce,{open:s,title:q(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),W()},onCancel:()=>{a||c(!1)}})]})}function _n(e){let t=(0,nt.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(O,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(gn,{...e}),t[0]=e,t[1]=n),n}function vn(e){let t=(0,nt.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:s}=e,c=i===void 0?!1:i,l;t[0]!==r||t[1]!==n?(l=mt(n,r),t[0]=r,t[1]=n,t[2]=l):l=t[2];let u=l.state,d;t[3]!==r||t[4]!==s?(d=r?Z(r,s):null,t[3]=r,t[4]=s,t[5]=d):d=t[5];let f=d,m,h,g,_,v,y,b,x,S;if(t[6]!==u||t[7]!==r||t[8]!==c||t[9]!==n||t[10]!==a||t[11]!==s.connectionChecking||t[12]!==s.connectionNeedsSetup||t[13]!==s.connectionReady){m=u===`ready`?{label:s.connectionReady,Icon:o,className:`text-emerald-700 dark:text-emerald-300`}:u===`needs_setup`?{label:s.connectionNeedsSetup,Icon:Oe,className:`text-amber-700 dark:text-amber-300`}:{label:s.connectionChecking,Icon:U,className:`text-fg-muted`},x=`button`;let e=c&&`bg-accent-soft`;t[23]===e?S=t[24]:(S=p(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,K.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=S),t[25]!==n||t[26]!==a?(h=()=>a(n),t[25]=n,t[26]=a,t[27]=h):h=t[27],t[28]===r?g=t[29]:(g=(0,$.jsx)(Ce,{connector:r}),t[28]=r,t[29]=g),b=`min-w-0 flex-1`,v=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?y=t[31]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=y),_=p(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,m.className),t[6]=u,t[7]=r,t[8]=c,t[9]=n,t[10]=a,t[11]=s.connectionChecking,t[12]=s.connectionNeedsSetup,t[13]=s.connectionReady,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[32]===m.Icon?C=t[33]:(C=(0,$.jsx)(m.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=m.Icon,t[33]=C);let w;t[34]!==m.label||t[35]!==C||t[36]!==_?(w=(0,$.jsxs)(`span`,{className:_,children:[C,m.label]}),t[34]=m.label,t[35]=C,t[36]=_,t[37]=w):w=t[37];let T;t[38]!==w||t[39]!==v||t[40]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[38]=w,t[39]=v,t[40]=y,t[41]=T):T=t[41];let E;t[42]===f?E=t[43]:(E=f?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}):null,t[42]=f,t[43]=E);let D;t[44]!==T||t[45]!==E||t[46]!==b?(D=(0,$.jsxs)(`div`,{className:b,children:[T,E]}),t[44]=T,t[45]=E,t[46]=b,t[47]=D):D=t[47];let O;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(he,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=O):O=t[48];let k;return t[49]!==h||t[50]!==g||t[51]!==D||t[52]!==x||t[53]!==S?(k=(0,$.jsxs)(`button`,{type:x,className:S,onClick:h,children:[g,D,O]}),t[49]=h,t[50]=g,t[51]=D,t[52]=x,t[53]=S,t[54]=k):k=t[54],k}function yn(e,t){return It()}function bn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[Ct()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function xn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,Ct(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Ct(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Sn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function Cn(){return p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z)}function wn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:u,headers:d,onChange:f,referenceLabel:m=`Existing credential reference`,showValueLabel:h=`Show value`,hideValueLabel:g=`Hide value`,allowPaste:_=!0}){let[v,y]=(0,Q.useState)(new Set),[b,x]=(0,Q.useState)(!1),S=(e,t)=>{f(d.map((n,r)=>r===e?{...n,...t}:n))},C=()=>{f([...d,Ct()])},w=e=>{let t=d.filter((t,n)=>n!==e);f(t.length>0?t:[Ct()])},E=async()=>{try{let e=await T();if(!e){x(!0);return}let t=Tt(e);if(!t?.length){x(!0);return}f(t)}catch{x(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),_?(0,$.jsxs)(F,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void E(),children:[(0,$.jsx)(V,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:p(Cn(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>S(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:p(Cn(),`min-w-0 font-mono text-xs`),type:v.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${u} ${t+1}`,readOnly:!!e.reference,value:e.reference?m:e.value,placeholder:e.reference?m:u,onChange:e=>S(t,{value:e.target.value})}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":v.has(e.clientKey)?g:h,onClick:()=>y(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:v.has(e.clientKey)?(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(l,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:d.length<=1&&!e.key&&!e.value,onClick:()=>w(t),"aria-label":r,children:(0,$.jsx)(ne,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:m}):null]},e.clientKey))}),(0,$.jsx)(ce,{open:b,title:o,description:a,confirmLabel:s,onConfirm:()=>x(!1),onCancel:()=>x(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:p(`self-start text-sm text-accent hover:underline`,K.press),onClick:C,children:[`+ `,n]})]})}var Tn=p(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,z);function En(e){let t=(0,nt.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o===void 0?!1:o,[c,u]=(0,Q.useState)(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=p(Tn,`mt-1.5`),t[0]=d):d=t[0];let f=c?`text`:`password`,m;t[1]===r?m=t[2]:(m=e=>r(e.target.value),t[1]=r,t[2]=m);let h;t[3]!==s||t[4]!==f||t[5]!==m||t[6]!==n?(h=(0,$.jsx)(`input`,{className:d,type:f,value:n,required:s,autoComplete:`off`,onChange:m}),t[3]=s,t[4]=f,t[5]=m,t[6]=n,t[7]=h):h=t[7];let g;t[8]!==i||t[9]!==h?(g=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,h]}),t[8]=i,t[9]=h,t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>u(Dn),t[11]=_):_=t[11];let v;t[12]===c?v=t[13]:(v=c?(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=v);let y=c?a.setupHideValue:a.setupShowValue,b;t[14]!==v||t[15]!==y?(b=(0,$.jsxs)(F,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:_,children:[v,y]}),t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;return t[17]!==b||t[18]!==g?(x=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[g,b]}),t[17]=b,t[18]=g,t[19]=x):x=t[19],x}function Dn(e){return!e}function On(e){let t=(0,nt.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(wn,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function kn(e){let t=(0,nt.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,s=i.setupAuthLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=p(Tn,`mt-1.5`),t[0]=c):c=t[0];let l=n.mode,u;t[1]===r?u=t[2]:(u=e=>r({mode:e.target.value}),t[1]=r,t[2]=u);let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=d):d=t[3];let f;t[4]===i.setupAuthModes?f=t[5]:(f=d.map(e=>(0,$.jsx)(Je,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=f);let m;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(m=a||n.mode===`existing`?(0,$.jsx)(Je,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=m):m=t[9];let h;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==u||t[13]!==f||t[14]!==m?(h=(0,$.jsxs)(Pe,{"aria-label":s,className:c,value:l,onChange:u,children:[f,m]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=u,t[13]=f,t[14]=m,t[15]=h):h=t[15];let g;t[16]!==i.setupAuthLabel||t[17]!==h?(g=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,h]}),t[16]=i.setupAuthLabel,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(_=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=_):_=t[21];let v;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(v=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=v):v=t[24];let y;t[25]!==n.mode||t[26]!==i.setupExistingHint?(y=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=y):y=t[27];let b;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(b=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(En,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=b):b=t[32];let x;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(x=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:p(Tn,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(En,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=x):x=t[38];let S;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(S=n.mode===`headers`?(0,$.jsx)(On,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=S):S=t[43];let C;return t[44]!==g||t[45]!==_||t[46]!==v||t[47]!==y||t[48]!==b||t[49]!==x||t[50]!==S?(C=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[g,_,v,y,b,x,S]}),t[44]=g,t[45]=_,t[46]=v,t[47]=y,t[48]=b,t[49]=x,t[50]=S,t[51]=C):C=t[51],C}function An(e){let t=(0,nt.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function jn({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>Dt(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=kt(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(An,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Tn,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Tn,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(ne,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(F,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(On,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Et(e)??{})})}})]})}function Mn(e){let t=(0,nt.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:s}=e,c=a===void 0?`all`:a,l=o===void 0?!1:o,u=s===void 0?!1:s,d=c!==`advanced`,f=c!==`basic`,p;t[0]!==d||t[1]!==i||t[2]!==n||t[3]!==r?(p=d?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Tn,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(jn,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(An,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Tn,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(An,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Tn,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=d,t[1]=i,t[2]=n,t[3]=r,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==u||t[7]!==i||t[8]!==n||t[9]!==l||t[10]!==r?(m=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Tn,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(An,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Tn,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(An,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Tn,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(An,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(Pe,{"aria-label":r.exposureLabel,className:Tn,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(Je,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(An,{label:r.requestTimeoutLabel,children:(0,$.jsx)(tt,{allowEmpty:!0,type:`number`,min:1,className:Tn,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=f,t[6]=u,t[7]=i,t[8]=n,t[9]=l,t[10]=r,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p,m]}),t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Nn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function Pn(e,t){return JSON.stringify({id:e.id,config:Rt(xn(e,t))})}function Fn(e,t){try{return Pn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function In(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[s,l]=(0,Q.useState)(()=>bn(e.initialRow)),[u,f]=(0,Q.useState)(`idle`),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[b,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[O,k]=(0,Q.useState)(),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),[P,L]=(0,Q.useState)(``),[R,z]=(0,Q.useState)(``),[B,V]=(0,Q.useState)([]),[H,U]=(0,Q.useState)(`0`),[W,G]=(0,Q.useState)(0),[ee,te]=(0,Q.useState)(``),[ne,K]=(0,Q.useState)(!1),[q,re]=(0,Q.useState)(!1),ie=e.mode===`edit`,[ae,oe]=(0,Q.useState)(``),J=(0,Q.useRef)(void 0),[se]=(0,Q.useState)(()=>Fn(e.initialRow,bn(e.initialRow))),le=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),ue=(0,Q.useRef)(void 0),Y=(0,Q.useRef)(void 0),X=(0,Q.useRef)(void 0),Z=(0,Q.useRef)(null),de=(0,Q.useRef)(``),fe=(0,Q.useRef)(!0),pe=(0,Q.useRef)(null),me=(0,Q.useRef)(null),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(e.onSaved);_e.current=e.onSaved;let ve=O?.state===`starting`||O?.state===`authorizing`,ye=u!==`idle`||ve,be=se!==Fn(i,s),xe=i.extra.enabled===!1,Se=!g&&(be||!!P.trim());(0,Q.useEffect)(()=>(fe.current=!0,()=>{fe.current=!1,ue.current?.abort(),Z.current?.close(),J.current&&Ht(J.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!Se)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Se]),(0,Q.useEffect)(()=>{if(!b)return;let e=he.current?.querySelector(`[data-field="${b.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),b.focus!==!1&&(n??ge.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[b,r]),(0,Q.useEffect)(()=>{if(!O||!ve)return;let e=new AbortController;Y.current=e;let n;async function r(){try{let n=await Gt(J.current,e.signal);if(e.signal.aborted||(k(n),n.authorizationUrl&&de.current!==n.authorizationUrl&&(de.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&h(t.oauthOpenFailed):Z.current&&!Z.current.closed&&Z.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){X.current=void 0,Z.current?.close(),D({state:`connected`,toolCount:n.toolCount}),h(``);return}if(n.state===`error`||n.state===`cancelled`){X.current=void 0,Z.current?.close(),h(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&j(!0);return}}catch{if(e.signal.aborted)return;Ce(),Z.current?.close(),h(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[O?.id,ve,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Ce(){ue.current?.abort(),Y.current?.abort(),J.current&&Ht(J.current).catch(()=>{}),J.current=void 0,oe(``),K(!1),D(void 0),k(void 0),h(``),T(void 0)}function we(e){a(t=>({...t,...e})),Ce()}function Te(e){l(t=>({...t,...e})),Ce()}function Ee(){u===`saving`||ve||(u===`checking`&&(Ce(),f(`idle`)),Se?re(!0):e.onClose())}function De(){try{V(Ft(P)),U(`0`),z(``)}catch{z(t.setupImportError),V([])}}function Oe(){let t=B[Number(H)];if(!t)return;let n={...t,id:le.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...le.current?{enabled:i.extra.enabled}:{}}};a(n),l(bn(n)),Ce(),G(e=>e+1),N(!1),L(``),V([])}function ke(e){function n(e,t){return T({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Pt(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(s.mode===`bearer`&&!s.token.trim().replace(/^Bearer\s*/i,``)||s.mode===`apiKey`&&(!s.apiKey.trim()||!s.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Sn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(s.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(s.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{Rt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function Ae(){h(``),f(`checking`),de.current=``,window.electronAPI?.shell?.openExternalUrl||(Z.current=window.open(`about:blank`,`_blank`),Z.current&&(Z.current.opener=null));try{let e=await Wt(J.current);if(!fe.current){Z.current?.close(),J.current&&Ht(J.current).catch(()=>{});return}X.current=e.id,k(e)}catch{Z.current?.close(),fe.current&&h(t.setupAuthFailed)}finally{fe.current&&f(`idle`)}}async function je(){let r=xn(i,s);if(!ke(r))return;let o=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==le.current),c=new Set([...e.managedServerIds,...o.map(e=>e.id)]);if(r.id=le.current||r.id.trim()||Nt(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){T({field:`advanced`,message:n.duplicateServerId});return}Ce(),f(`checking`);let l=new AbortController;ue.current=l;try{let n=await Bt(r,le.current||void 0,e.initialRow.extra,l.signal);if(!fe.current||l.signal.aborted){Ht(n.id).catch(()=>{});return}J.current=n.id,a(r),oe(Fn(r,s));let i=await Vt(n.id,l.signal);if(!fe.current||l.signal.aborted)return;D(i),i.state===`error`&&h(Nn(i,t))}catch(e){fe.current&&!l.signal.aborted&&h(e.status===409?t.setupConflict:Nn(e,t))}finally{fe.current&&ue.current===l&&f(`idle`)}}async function Me(n=!1){if(!(!J.current||E?.state!==`connected`||ae!==Fn(i,s))){f(`saving`),h(``);try{let t=await Ut(J.current,n);J.current=void 0,await _e.current().catch(()=>{}),t?.reloadRequired?_(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(Ce(),h(t.setupConflict)):h(t.setupSaveFailed)}finally{fe.current&&f(`idle`)}}}async function Ne(){Y.current?.abort();let e=J.current;X.current=void 0,k(void 0),Z.current?.close(),h(t.setupCancelled),f(`checking`);try{e&&await Kt(e)}catch{fe.current&&(Ce(),h(t.setupCancelled))}finally{fe.current&&f(`idle`)}}async function Fe(){O?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(O.authorizationUrl)).ok||h(t.oauthOpenFailed):window.open(O.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Ie(){if(O)try{await qt(J.current,ee),te(``),h(``)}catch{h(t.setupRedirectInvalid)}}let Le=!!J.current&&ae===Fn(i,s)&&(s.mode===`oauth`||s.mode===`auto`&&E?.state===`oauth_required`)&&E?.state!==`connected`,Re=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),ze=B[Number(H)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{open:e.open,onOpenChange:e=>{e||Ee()},children:(0,$.jsxs)(x,{children:[(0,$.jsx)(v,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(S,{ref:pe,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),pe.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(C,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(y,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:u===`saving`||ve,onClick:Ee,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(d,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[M?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>N(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:p(Tn,`mt-1.5 min-h-40 font-mono text-xs`),value:P,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{L(e.target.value),V([]),z(``)}})]}),(0,$.jsx)(F,{variant:`secondary`,disabled:!P.trim(),onClick:De,children:t.setupImportPreview}),R?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:R}):null,ze?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(Pe,{"aria-label":t.setupImportChoose,className:p(Tn,`mt-1.5`),value:H,onChange:e=>U(e.target.value),children:B.map((e,t)=>(0,$.jsx)(Je,{value:String(t),children:e.displayName||e.id||en(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[ze.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,en(ze)]})]}):null]}):(0,$.jsxs)(`form`,{ref:he,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Pt(i.url)}catch{T({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),je()},children:[(0,$.jsxs)(`fieldset`,{disabled:ye||g,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(F,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>we({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>N(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Mn,{row:i,t,variant:`basic`,onUpdate:we},`${i.transport}-${W}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(kn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:s,onChange:Te,t})}):null,b?(0,$.jsx)(`p`,{id:r,ref:ge,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:b.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:A,onToggle:e=>j(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Mn,{row:i,t,variant:`advanced`,idReadOnly:ie,showOAuth:s.mode===`oauth`,onUpdate:we}),i.transport===`streamable-http`&&s.mode!==`headers`&&s.mode!==`existing`?(0,$.jsx)(On,{additional:!0,headers:s.additionalHeaders,onChange:e=>Te({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:Re?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),g?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!M&&!g?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[u===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(I,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),u===`saving`?t.setupSaving:t.setupChecking]}),u===`idle`&&ie&&!be&&!E&&!m&&!ve?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:xe?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,E?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(o,{className:`size-4 shrink-0`,"aria-hidden":!0}),E.toolCount?t.setupConnected.replace(`{{count}}`,String(E.toolCount)):t.setupZeroTools]}),(0,$.jsx)(F,{ref:me,variant:`secondary`,onClick:()=>K(!0),children:t.viewTools})]}):null,E?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,E?.state===`oauth_required`&&!ve?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,ve?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(I,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[O?.authorizationUrl?(0,$.jsxs)(F,{variant:`secondary`,onClick:()=>void Fe(),children:[(0,$.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(F,{variant:`ghost`,onClick:()=>void Ne(),children:t.setupCancelAuth})]}),O?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:Tn,value:ee,onChange:e=>te(e.target.value)})]}),(0,$.jsx)(F,{className:`mt-2`,disabled:!ee.trim(),onClick:()=>void Ie(),children:t.setupContinue})]}):null]}):null,m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:m}),m!==t.setupSaveFailed&&u!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(F,{variant:`secondary`,disabled:u===`saving`||ve,onClick:Ee,children:ie||g?t.setupClose:n.modalCancel}),g?null:M?(0,$.jsx)(F,{variant:`primary`,disabled:!ze,onClick:Oe,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{variant:E?.state===`connected`?`secondary`:`primary`,disabled:ye,onClick:()=>Le?void Ae():void je(),children:Le?t.setupSignIn:t.setupTestConnection}),E?.state===`connected`&&ae===Fn(i,s)?(0,$.jsxs)($.Fragment,{children:[xe?(0,$.jsx)(F,{variant:`secondary`,disabled:ye,onClick:()=>void Me(!0),children:t.setupEnableSave}):null,(0,$.jsx)(F,{variant:`primary`,disabled:ye,"aria-busy":ye,onClick:()=>void Me(),children:ie?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(ce,{open:q,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>re(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),ne?(0,$.jsx)(Zt,{draftId:J.current,serverId:i.id,displayName:i.displayName,returnFocusTo:me.current,t,onClose:()=>K(!1)}):null]})}var Ln=`builtin`,Rn=`composio`,zn=`xopc-store`;function Bn(e){return Ln}function Vn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function Hn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Un(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function Wn({embedded:e=!1,onHeaderActionChange:t}){let n=W().filter(e=>e.format===`agent-plugin`),r=g(e=>e.language),o=f(r),s=o.connectorsSettings,c=o.mcpSettings,l=h(e=>e.conversationId),u=!!l,d=i(),[m,_]=a(),v=m.get(`understanding`)===`1`,y=Un(m.get(`returnTo`)),b=!!m.get(`returnTo`)&&!v,x=m.get(`tab`),[S,C]=(0,Q.useState)(!v&&x===`connected`?`connected`:`discover`),w=(0,Q.useRef)(!1),[T,E]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(1),[P,L]=(0,Q.useState)(void 0),[R,z]=(0,Q.useState)(``),[V,U]=(0,Q.useState)(v||b?m.get(`connector`)??``:``),[G,ee]=(0,Q.useState)(Bn(v?`understanding`:`default`)),[te,ne]=(0,Q.useState)(`name`),[K,q]=(0,Q.useState)(v?`understand`:`all`),[re,ie]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(null),[se,ce]=(0,Q.useState)(null),[le,Z]=(0,Q.useState)(null),[de,fe]=(0,Q.useState)(null),[me,he]=(0,Q.useState)(null),{data:ge,mutate:_e}=D(u),ve=ge?.payload?.config,be=(0,Q.useMemo)(()=>ve===void 0?null:Lt(ve),[ve]),xe=be?.servers??[],Se=T.instances.length+xe.length+n.reduce((e,t)=>e+(t.components?.mcp.length??0),0),[Ce,we]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(we({}),!u||!ve)return;let e=new AbortController;return Yt(e.signal).then(t=>{e.signal.aborted||we(t)}).catch(()=>{}),()=>e.abort()},[u,ve]);let Te=(0,Q.useCallback)(async()=>{if(!l){E({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}E(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Ie(),Ue()]);E(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){E({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[l]);(0,Q.useEffect)(()=>{Te()},[Te]),(0,Q.useEffect)(()=>{w.current||T.loading||u&&!be||(C(v?`discover`:Se>0?`connected`:`discover`),w.current=!0)},[u,Se,be,v,T.loading]);let Ee=(0,Q.useCallback)(e=>{w.current=!0,C(e)},[]),Oe=(0,Q.useMemo)(()=>[{id:Rn,displayName:s.composioSourceName},{id:zn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),ke=(0,Q.useCallback)(async e=>{if(!u||G===`builtin`){E(e=>({...e,registryCatalog:[]})),N(1),L(void 0);return}let t=V.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=G===`all`?Oe:Oe.filter(e=>e.id===G);if(i.length!==0){k(!0),r?E(e=>({...e,error:null})):(N(1),L(void 0),E(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await Ke({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await De({q:t||void 0,page:n,pageSize:24,sort:te===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Vn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Hn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));N(n),L(o),E(e=>({...e,registryCatalog:r?Hn([...e.registryCatalog,...a]):a}))}catch(e){E(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{k(!1)}}},[te,V,G,u,Oe]);(0,Q.useEffect)(()=>{if(S!==`discover`||T.loading)return;if(G===`builtin`){E(e=>({...e,registryCatalog:[]})),N(1),L(void 0);return}let e=window.setTimeout(()=>{ke()},V.trim()?350:0);return()=>window.clearTimeout(e)},[V,G,ke,T.loading,S]);let Ae=(0,Q.useMemo)(()=>new Set(T.instances.map(e=>e.connectorId)),[T.instances]),je=(0,Q.useMemo)(()=>new Map([...T.catalog,...T.registryCatalog].map(e=>[e.id,e])),[T.catalog,T.registryCatalog]);(0,Q.useEffect)(()=>{if(T.loading)return;let e=m.get(`connector`),t=m.get(`instance`);if(!e&&!t)return;let n=T.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)w.current=!0,z(``),ce(n.instanceId),Z(n),C(`connected`);else if(e){let t=je.get(e);if(!t)return;w.current=!0,ee(Bn(v?`understanding`:`default`)),U(``),oe(t),C(`discover`)}let r=new URLSearchParams(m);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),_(r,{replace:!0})},[je,v,m,_,T.instances,T.loading]);let Me=(0,Q.useCallback)(async e=>{j(!0),E(e=>({...e,error:null}));try{let t=await pe(e);ie(B(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){E(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{j(!1)}},[]),Ne=(0,Q.useMemo)(()=>new Set(T.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[T.instances]),Pe=(0,Q.useCallback)(async e=>{let t=await Xt(e);await _e(),await Te(),t.reloadRequired&&E(e=>({...e,error:c.setupReloadRequired}))},[Te,_e,c.setupReloadRequired]),Fe=(0,Q.useCallback)(()=>{he({mode:`add`,row:yn(xe,Ne)})},[xe,Ne]),Le=J(e=>e.setPageHeader),ze=J(e=>e.clearPageHeader),Be=(0,Q.useMemo)(()=>({searchLabel:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(Ze,{value:S===`connected`?R:V,onChange:S===`connected`?z:U,placeholder:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(St,{onRefresh:S===`connected`&&u?Te:void 0,refreshing:T.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>Ee(`discover`),onAddCustomServer:Fe,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[R,s,V,u,r,Te,o.capabilitiesHub.moreActions,Fe,Ee,T.loading,S]);(0,Q.useLayoutEffect)(()=>e?(t?.(Be),()=>t?.(null)):(Le({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:s.title})}),end:(0,$.jsx)(Qe,{contribution:Be})}),()=>ze()),[ze,s.title,e,Be,t,Le]);let Ve=(0,Q.useMemo)(()=>T.instances.map(e=>({instance:e,value:mt(e,je.get(e.connectorId))})),[je,T.instances]),We=(0,Q.useMemo)(()=>new Map(Ve.map(({instance:e,value:t})=>[e.instanceId,t])),[Ve]),Ge=(0,Q.useMemo)(()=>T.instances.filter(e=>X(e,R)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=We.get(e.instanceId)?.state??`checking`,i=We.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[R,We,T.instances]),qe=(0,Q.useMemo)(()=>Ge.filter(e=>We.get(e.instanceId)?.state===`needs_setup`),[We,Ge]),Je=(0,Q.useMemo)(()=>Ge.filter(e=>We.get(e.instanceId)?.state!==`needs_setup`),[We,Ge]),Ye=(0,Q.useMemo)(()=>xe.filter(e=>He(e,R)),[R,xe]),Xe=(0,Q.useMemo)(()=>{let e=R.trim().toLowerCase();return n.flatMap(t=>(t.components?.mcp??[]).filter(n=>`${t.name} ${n.name}`.toLowerCase().includes(e)).map(e=>({extension:t,server:e})))},[R,n]),$e=Ge.length+Ye.length+Xe.length,tt=(0,Q.useMemo)(()=>T.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&ue(e)),[T.catalog]),nt=(0,Q.useMemo)(()=>G===`builtin`?tt:G===`all`?Hn([...tt,...T.registryCatalog]):T.registryCatalog,[tt,G,T.registryCatalog]),it=(0,Q.useMemo)(()=>{let e=v?nt.filter(e=>e.understanding?.mode===`activity`):nt;return H(K===`all`?e:e.filter(e=>ft(e).includes(K)),V,te)},[te,V,nt,v,K]),st=(0,Q.useMemo)(()=>dt.filter(e=>nt.some(t=>ft(t).includes(e))),[nt]);(0,Q.useEffect)(()=>{K!==`all`&&!st.includes(K)&&q(`all`)},[st,K]);let lt=S===`discover`&&G!==`builtin`&&!!(P&&M<P),pt=(0,Q.useMemo)(()=>T.instances.find(e=>e.instanceId===se)??le,[se,le,T.instances]),ht=(0,Q.useMemo)(()=>[{value:`all`,label:s.discoverSourceAll},{value:Ln,label:s.discoverSourceBuiltin},...Oe.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,Oe]),gt=[{id:`connected`,label:s.tabConnected,count:Se},{id:`discover`,label:s.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:p(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[u?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),v?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>d(y),children:s.understandingSetupDone})]}):null,b?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>d(y),children:s.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(Re,{items:gt,activeTab:S,onChange:Ee,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),T.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:T.error}):null,S===`connected`&&u?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:T.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":s.loading,children:at.slice(0,3).map(e=>(0,$.jsx)(ut,{},e))}):Se===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(F,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Ee(`discover`),children:s.addFromCatalog})]}):$e===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[qe.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:qe.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:qe.map(e=>(0,$.jsx)(vn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===de,onOpenDetails:e=>{fe(null),ce(e.instanceId),Z(e)},t:s},e.instanceId))})]}):null,Je.length?(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Je.map(e=>(0,$.jsx)(vn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===de,onOpenDetails:e=>{fe(null),ce(e.instanceId),Z(e)},t:s},e.instanceId))})}):null,Xe.map(({extension:e,server:t})=>(0,$.jsx)(et,{pluginId:e.pluginId,server:t,enabled:e.active},t.id)),Ye.length||!R.trim()?(0,$.jsxs)(`section`,{"aria-label":s.customIntegrationsTitle,className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`h2`,{className:`inline text-sm font-medium text-fg`,children:s.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:Ye.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:s.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Fe,children:s.addCustomServerAdvanced})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ye.map(e=>(0,$.jsx)(tn,{row:e,lastCheck:Ce[e.id],t:c,cs:s,onEdit:()=>he({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Pe(e)},e.clientKey))})]})]}):null]})}):null,S===`discover`&&u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[v?null:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,children:[`all`,...st].map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,K===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":K===e,onClick:()=>q(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:p(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,v?`grid-cols-1`:`grid-cols-2`),children:[v?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(ye,{value:G,options:ht,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ee})}),(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(ye,{value:te,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>ne(e)})})]})]}),(T.loading||O)&&it.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:at.map(e=>(0,$.jsx)(ct,{},e))}):it.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[O?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":s.loading,children:(0,$.jsx)(I,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:it.map(e=>(0,$.jsx)(rt,{connector:e,installed:Ae.has(e.id)||ot(e,T.instances),onInstall:e=>{if(e.source===`store`){Me(e.id);return}ie(B(e))},onOpenDetails:e.source===`store`?void 0:oe,t:s},e.id))}),lt?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(F,{type:`button`,variant:`secondary`,disabled:O||A,onClick:()=>void ke({page:M+1,append:!0}),children:[O?(0,$.jsx)(I,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),re?(0,$.jsx)(Y,{draft:re,onChange:ie,onClose:()=>ie(null),t:s,onInstalled:async e=>{await Te(),await _e(),fe(e.instanceId),Ee(`connected`)}}):null,ae?(0,$.jsx)(vt,{connector:ae,installed:Ae.has(ae.id)||ot(ae,T.instances),onClose:()=>oe(null),onInstall:e=>ie(B(e)),t:s}):null,pt?(0,$.jsx)(_n,{instance:pt,definition:je.get(pt.connectorId),onClose:()=>{ce(null),Z(null)},onChanged:Te,t:s,mcp:c}):null,me?(0,$.jsx)(In,{open:!0,mode:me.mode,initialRow:me.row,lastCheck:me.mode===`edit`?Ce[me.row.id]:void 0,existingCustomServers:xe,config:ve,managedServerIds:Ne,t:c,cs:s,onClose:()=>he(null),onSaved:async()=>{await _e(),await Te(),Ee(`connected`)}},`${me.mode}-${me.row.clientKey}`):null]})})}export{Wn as ConnectorsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-0WouolD0.js";import{n as a}from"./locale-store-CE7L6MlS.js";import{Es as o,Ts as ee,af as te,bs as ne,cf as re,hs as ie,ms as ae,of as oe,ps as se}from"./index-CKdOZoVu.js";var s=e(t(),1),ce=n();function c(e){return String(e).padStart(2,`0`)}function le(e){return`${e.getFullYear()}-${c(e.getMonth()+1)}-${c(e.getDate())}`}function ue(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2])-1,i=Number(t[3]),a=new Date(n,r,i,12);return a.getFullYear()===n&&a.getMonth()===r&&a.getDate()===i?a:null}function de(e,t){let n=ue(e);return n?t===`zh`?`${n.getFullYear()}/${c(n.getMonth()+1)}/${c(n.getDate())}`:new Intl.DateTimeFormat(`en`,{year:`numeric`,month:`short`,day:`numeric`}).format(n):``}var l=r();function fe(e,t){let n=new Date(e.getFullYear(),e.getMonth(),1,12),r=(n.getDay()-t+7)%7;return Array.from({length:42},(e,t)=>new Date(n.getFullYear(),n.getMonth(),1-r+t,12))}function u(e){let t=(0,ce.c)(105),{value:n,onChange:r,disabled:c,className:u,ariaLabel:_e,placeholder:ve,min:d,max:f}=e,p=a(ge),m=p===`zh`?`zh-CN`:`en`,ye;t[0]===n?ye=t[1]:(ye=ue(n),t[0]=n,t[1]=ye);let h=ye,[g,be]=(0,s.useState)(!1),[xe,Se]=(0,s.useState)(null),_;t[2]===h?_=t[3]:(_=()=>h??new Date,t[2]=h,t[3]=_);let[v,Ce]=(0,s.useState)(_),we=se(xe),Te=ie(ae(),we!==null),y=+(p===`zh`),b,x;t[4]!==g||t[5]!==n?(b=()=>{if(!g)return;let e=ue(n);e&&Ce(e)},x=[g,n],t[4]=g,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),(0,s.useEffect)(b,x);let S;t[8]!==v||t[9]!==y?(S=fe(v,y),t[8]=v,t[9]=y,t[10]=S):S=t[10];let Ee=S,C;if(t[11]!==m||t[12]!==y){let e=new Date(2026,7,23,12);C=Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(e.getDate()+y+n),new Intl.DateTimeFormat(m,{weekday:`narrow`}).format(r)}),t[11]=m,t[12]=y,t[13]=C}else C=t[13];let De=C,w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=le(new Date),t[14]=w):w=t[14];let T=w,E;t[15]===h?E=t[16]:(E=h?le(h):``,t[15]=h,t[16]=E);let D=E,O;t[17]!==m||t[18]!==v?(O=new Intl.DateTimeFormat(m,{year:`numeric`,month:`long`}).format(v),t[17]=m,t[18]=v,t[19]=O):O=t[19];let Oe=O,k;t[20]===r?k=t[21]:(k=e=>{r(e),be(!1)},t[20]=r,t[21]=k);let A=k,ke=o,Ae=c&&`cursor-not-allowed opacity-50`,j;t[22]!==u||t[23]!==Ae?(j=i(`flex h-10 w-full min-w-0 items-center justify-between gap-3 rounded-lg bg-surface-hover px-3 text-left text-sm text-fg outline-none transition-colors`,`hover:bg-surface-active focus-visible:ring-2 focus-visible:ring-accent/40`,Ae,u),t[22]=u,t[23]=Ae,t[24]=j):j=t[24];let je=!n&&`text-fg-subtle`,M;t[25]===je?M=t[26]:(M=i(`min-w-0 truncate tabular-nums`,je),t[25]=je,t[26]=M);let N;t[27]!==p||t[28]!==ve||t[29]!==n?(N=de(n,p)||ve||(p===`zh`?`选择日期`:`Select date`),t[27]=p,t[28]=ve,t[29]=n,t[30]=N):N=t[30];let P;t[31]!==M||t[32]!==N?(P=(0,l.jsx)(`span`,{className:M,children:N}),t[31]=M,t[32]=N,t[33]=P):P=t[33];let F;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,l.jsx)(re,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=F):F=t[34];let I;t[35]!==_e||t[36]!==c||t[37]!==j||t[38]!==P?(I=(0,l.jsx)(ee,{asChild:!0,children:(0,l.jsxs)(`button`,{ref:Se,type:`button`,disabled:c,"aria-label":_e,className:j,children:[P,F]})}),t[35]=_e,t[36]=c,t[37]=j,t[38]=P,t[39]=I):I=t[39];let Me=o,Ne=we??void 0,Pe=o,Fe=i(Te,`w-[19rem] rounded-2xl border border-edge bg-surface-overlay p-3 shadow-float outline-none`),Ie=p===`zh`?`上个月`:`Previous month`,L,R;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>Ce(he),R=(0,l.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[40]=L,t[41]=R):(L=t[40],R=t[41]);let z;t[42]===Ie?z=t[43]:(z=(0,l.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Ie,onClick:L,children:R}),t[42]=Ie,t[43]=z);let B;t[44]===Oe?B=t[45]:(B=(0,l.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:Oe}),t[44]=Oe,t[45]=B);let Le=p===`zh`?`下个月`:`Next month`,V,Re;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>Ce(me),Re=(0,l.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[46]=V,t[47]=Re):(V=t[46],Re=t[47]);let H;t[48]===Le?H=t[49]:(H=(0,l.jsx)(`button`,{type:`button`,className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,"aria-label":Le,onClick:V,children:Re}),t[48]=Le,t[49]=H);let U;t[50]!==z||t[51]!==B||t[52]!==H?(U=(0,l.jsxs)(`div`,{className:`flex h-10 items-center justify-between gap-2 px-1`,children:[z,B,H]}),t[50]=z,t[51]=B,t[52]=H,t[53]=U):U=t[53];let W;t[54]===De?W=t[55]:(W=(0,l.jsx)(`div`,{className:`mt-2 grid grid-cols-7`,"aria-hidden":!0,children:De.map(pe)}),t[54]=De,t[55]=W);let G;if(t[56]!==Ee||t[57]!==m||t[58]!==f||t[59]!==d||t[60]!==A||t[61]!==D||t[62]!==v){let e;t[64]!==m||t[65]!==f||t[66]!==d||t[67]!==A||t[68]!==D||t[69]!==v?(e=e=>{let t=le(e),n=t===D,r=t===T,a=e.getMonth()!==v.getMonth(),o=!!(d&&t<d||f&&t>f);return(0,l.jsx)(`button`,{type:`button`,role:`gridcell`,"aria-selected":n,"aria-disabled":o,disabled:o,"aria-label":new Intl.DateTimeFormat(m,{dateStyle:`full`}).format(e),className:i(`mx-auto flex size-9 items-center justify-center rounded-xl text-sm tabular-nums text-fg transition-colors`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a&&`text-fg-disabled`,o&&`cursor-not-allowed opacity-35 hover:bg-transparent`,r&&!n&&`bg-accent-soft font-semibold text-accent-fg`,n&&`bg-accent font-semibold text-on-accent hover:bg-accent-hover`),onClick:()=>A(t),children:e.getDate()},t)},t[64]=m,t[65]=f,t[66]=d,t[67]=A,t[68]=D,t[69]=v,t[70]=e):e=t[70],G=Ee.map(e),t[56]=Ee,t[57]=m,t[58]=f,t[59]=d,t[60]=A,t[61]=D,t[62]=v,t[63]=G}else G=t[63];let K;t[71]===G?K=t[72]:(K=(0,l.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1`,role:`grid`,children:G}),t[71]=G,t[72]=K);let ze=!n,q;t[73]===A?q=t[74]:(q=()=>A(``),t[73]=A,t[74]=q);let Be=p===`zh`?`清除`:`Clear`,J;t[75]!==ze||t[76]!==q||t[77]!==Be?(J=(0,l.jsx)(`button`,{type:`button`,disabled:ze,className:`rounded-lg px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg disabled:pointer-events-none disabled:opacity-35`,onClick:q,children:Be}),t[75]=ze,t[76]=q,t[77]=Be,t[78]=J):J=t[78];let Ve=!!(d&&T<d||f&&T>f),Y;t[79]===A?Y=t[80]:(Y=()=>A(T),t[79]=A,t[80]=Y);let He=p===`zh`?`今天`:`Today`,X;t[81]!==Ve||t[82]!==Y||t[83]!==He?(X=(0,l.jsx)(`button`,{type:`button`,disabled:Ve,className:`rounded-lg bg-accent-soft px-2.5 py-1.5 text-xs font-medium text-accent-fg hover:bg-accent-soft/80 disabled:pointer-events-none disabled:opacity-35`,onClick:Y,children:He}),t[81]=Ve,t[82]=Y,t[83]=He,t[84]=X):X=t[84];let Z;t[85]!==J||t[86]!==X?(Z=(0,l.jsxs)(`div`,{className:`mt-2 flex items-center justify-between px-1 pt-1`,children:[J,X]}),t[85]=J,t[86]=X,t[87]=Z):Z=t[87];let Ue;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=(0,l.jsx)(ne,{className:`fill-surface-overlay`}),t[88]=Ue):Ue=t[88];let Q;t[89]!==Pe.Content||t[90]!==Fe||t[91]!==U||t[92]!==W||t[93]!==K||t[94]!==Z?(Q=(0,l.jsxs)(Pe.Content,{align:`start`,sideOffset:6,collisionPadding:12,className:Fe,children:[U,W,K,Z,Ue]}),t[89]=Pe.Content,t[90]=Fe,t[91]=U,t[92]=W,t[93]=K,t[94]=Z,t[95]=Q):Q=t[95];let $;t[96]!==Me.Portal||t[97]!==Ne||t[98]!==Q?($=(0,l.jsx)(Me.Portal,{container:Ne,children:Q}),t[96]=Me.Portal,t[97]=Ne,t[98]=Q,t[99]=$):$=t[99];let We;return t[100]!==g||t[101]!==ke.Root||t[102]!==I||t[103]!==$?(We=(0,l.jsxs)(ke.Root,{open:g,onOpenChange:be,children:[I,$]}),t[100]=g,t[101]=ke.Root,t[102]=I,t[103]=$,t[104]=We):We=t[104],We}function pe(e,t){return(0,l.jsx)(`div`,{className:`flex h-8 items-center justify-center text-[11px] font-medium text-fg-subtle`,children:e},`${e}-${t}`)}function me(e){return new Date(e.getFullYear(),e.getMonth()+1,1,12)}function he(e){return new Date(e.getFullYear(),e.getMonth()-1,1,12)}function ge(e){return e.language}export{u as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as e}from"./locale-store-CE7L6MlS.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{g as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./messages-CaeL_miw.js";import{t as o}from"./cn-0WouolD0.js";import{a as s,c,n as l,r as u}from"./locale-store-CE7L6MlS.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{n as p,r as m}from"./gateway-config-swr-BEePO3Wl.js";import{As as h,Bn as g,Dl as _,Du as v,G as y,Gl as b,Hc as x,Hu as S,Ic as C,Is as w,Jl as T,Kl as E,Ms as D,On as O,Pc as k,Xa as A,Zn as j,ad as M,as as N,au as P,if as F,js as I,ls as L,ns as R,ru as ee,sd as z,to as te,us as B}from"./index-CKdOZoVu.js";import{t as V}from"./number-input-DDeqHK-G.js";import{n as ne,r as re,t as H}from"./settings-page-layout-Dx5S-Msc.js";import{n as ie,t as ae}from"./settings-form-section-DCSHPFAN.js";import{t as oe}from"./settings-advanced-gate-C7zklouD.js";var U=e(t(),1),W=n(),se=18790,G={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function K(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function q(e){return D(e)}async function ce(e){let t=await s(u(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function J(e){return q(e)?``:e.trim()}function Y(e){return[...e].map(e=>e.trim()).sort()}function le(e){return JSON.stringify({outboundProxy:e.outboundProxy,bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:J(e.auth.token),password:J(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:Y(e.auth.trustedProxy.requiredHeaders),allowUsers:Y(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},trustedProxies:Y(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function ue(e,t){return le(e)!==le(t)}async function de(e){return(await s(u(`/api/gateway/cors-origin-candidates?port=${encodeURIComponent(String(e))}`))).payload?.candidates??[]}function fe(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function pe(e){let t=K(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):G.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):G.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):G.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function X(e){let t=K(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:Z(t.requiredHeaders,32),allowUsers:Z(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function me(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function Z(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function he(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function ge(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function _e(e){try{let t=new URL(e.trim());return[`http:`,`https:`].includes(t.protocol)&&!!t.hostname&&!t.username&&!t.password&&!t.search&&!t.hash&&(!t.pathname||t.pathname===`/`)}catch{return!1}}function ve(e){let t=e.outboundProxy;if((t.mode===`custom`||t.url.trim())&&!_e(t.url))return`Use an HTTP or HTTPS proxy origin without credentials, path, query or fragment.`;let n=ge(e);return n&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:n&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:n&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function ye(e){let t=K(e)?e:{},n=K(t.gateway)?t.gateway:{},r=K(n.auth)?n.auth:{},i=K(n.security)?n.security:{},a=K(t.update)?t.update:{},o=K(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[],u=he(n.bind),d=typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,f=K(n.outboundProxy)?n.outboundProxy:{};return{outboundProxy:{mode:f.mode===`custom`||f.mode===`direct`?f.mode:`environment`,url:typeof f.url==`string`?f.url:``,noProxy:typeof f.noProxy==`string`?f.noProxy:``},bind:u,customBindHost:d,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):se,auth:{mode:fe(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:pe(r.rateLimit),trustedProxy:X(r.trustedProxy)},corsOrigins:l,trustedProxies:Z(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:me(n.channelConnectDeferMode),channelConnectDeferIds:Z(n.channelConnectDeferIds),channelConnectDeferSkipIds:Z(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function be(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!q(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!q(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function xe(e){let t=ve(e);if(t)throw Error(t);await s(u(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{outboundProxy:e.outboundProxy,bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:be(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),p()}var Q=r();function Se(e){let t=(0,W.c)(46),{value:n,onChange:r,g:i}=e,[a,s]=(0,U.useState)(!1),c;t[0]!==a||t[1]!==n.mode||t[2]!==n.url?(c=a&&n.mode===`custom`&&!_e(n.url),t[0]=a,t[1]=n.mode,t[2]=n.url,t[3]=c):c=t[3];let l=c,u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,w),t[4]=u):u=t[4];let d=u,f;t[5]===i.outboundProxyTitle?f=t[6]:(f=(0,Q.jsx)(`h2`,{id:`outbound-proxy-title`,className:`text-sm font-semibold text-fg`,children:i.outboundProxyTitle}),t[5]=i.outboundProxyTitle,t[6]=f);let p;t[7]===i.outboundProxyHint?p=t[8]:(p=(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.outboundProxyHint}),t[7]=i.outboundProxyHint,t[8]=p);let m;t[9]===i.outboundProxyMode?m=t[10]:(m=(0,Q.jsx)(`label`,{htmlFor:`outbound-proxy-mode`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyMode}),t[9]=i.outboundProxyMode,t[10]=m);let h;t[11]!==r||t[12]!==n?(h=e=>r({...n,mode:e.target.value}),t[11]=r,t[12]=n,t[13]=h):h=t[13];let g;t[14]===i.outboundProxyEnvironment?g=t[15]:(g=(0,Q.jsx)(B,{value:`environment`,children:i.outboundProxyEnvironment}),t[14]=i.outboundProxyEnvironment,t[15]=g);let _;t[16]===i.outboundProxyCustom?_=t[17]:(_=(0,Q.jsx)(B,{value:`custom`,children:i.outboundProxyCustom}),t[16]=i.outboundProxyCustom,t[17]=_);let v;t[18]===i.outboundProxyDirect?v=t[19]:(v=(0,Q.jsx)(B,{value:`direct`,children:i.outboundProxyDirect}),t[18]=i.outboundProxyDirect,t[19]=v);let y;t[20]!==h||t[21]!==g||t[22]!==_||t[23]!==v||t[24]!==n.mode?(y=(0,Q.jsxs)(L,{id:`outbound-proxy-mode`,value:n.mode,onChange:h,children:[g,_,v]}),t[20]=h,t[21]=g,t[22]=_,t[23]=v,t[24]=n.mode,t[25]=y):y=t[25];let b;t[26]!==y||t[27]!==m?(b=(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[m,y]}),t[26]=y,t[27]=m,t[28]=b):b=t[28];let x;t[29]!==i.outboundProxyInvalid||t[30]!==i.outboundProxyUrl||t[31]!==l||t[32]!==r||t[33]!==n?(x=n.mode===`custom`&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`outbound-proxy-url`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyUrl}),(0,Q.jsx)(`input`,{id:`outbound-proxy-url`,className:d,value:n.url,placeholder:`http://127.0.0.1:7897`,autoComplete:`off`,spellCheck:!1,"aria-invalid":l,"aria-describedby":l?`outbound-proxy-error`:void 0,onChange:e=>r({...n,url:e.target.value}),onBlur:()=>s(!0)}),l&&(0,Q.jsx)(`p`,{id:`outbound-proxy-error`,role:`alert`,className:`text-xs text-danger`,children:i.outboundProxyInvalid})]}),t[29]=i.outboundProxyInvalid,t[30]=i.outboundProxyUrl,t[31]=l,t[32]=r,t[33]=n,t[34]=x):x=t[34];let S;t[35]!==i.outboundProxyBypass||t[36]!==i.outboundProxyBypassHint||t[37]!==r||t[38]!==n?(S=n.mode!==`direct`&&(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsx)(`label`,{htmlFor:`outbound-proxy-bypass`,className:`block text-sm font-medium text-fg`,children:i.outboundProxyBypass}),(0,Q.jsx)(`input`,{id:`outbound-proxy-bypass`,className:d,value:n.noProxy,placeholder:`.example.com,192.168.1.10`,autoComplete:`off`,spellCheck:!1,"aria-describedby":`outbound-proxy-bypass-hint`,onChange:e=>r({...n,noProxy:e.target.value})}),(0,Q.jsx)(`p`,{id:`outbound-proxy-bypass-hint`,className:`text-xs text-fg-muted`,children:i.outboundProxyBypassHint})]}),t[35]=i.outboundProxyBypass,t[36]=i.outboundProxyBypassHint,t[37]=r,t[38]=n,t[39]=S):S=t[39];let C;return t[40]!==b||t[41]!==x||t[42]!==S||t[43]!==f||t[44]!==p?(C=(0,Q.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,"aria-labelledby":`outbound-proxy-title`,children:[f,p,b,x,S]}),t[40]=b,t[41]=x,t[42]=S,t[43]=f,t[44]=p,t[45]=C):C=t[45],C}var Ce={critical:3,warn:2,info:1};function we(){return u(`/api/doctor?security=true`)}function Te(e){return e.toSorted((e,t)=>Ce[t.severity]-Ce[e.severity]||e.checkId.localeCompare(t.checkId))}function Ee(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=Te((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function De(){return Ee(await s(we()))}function Oe(e){let t=(0,W.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,o=l(Ae),s;t[0]===o?s=t[1]:(s=a(o),t[0]=o,t[1]=s);let c=s.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[we(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:h,isLoading:g,isValidating:_,mutate:v}=d(u,ke,p),y=m??null,b=h instanceof Error?h.message:h?String(h):null,w=g||_,E;t[6]===v?E=t[7]:(E=()=>{v(),f(we())},t[6]=v,t[7]=E);let D=E,O=!n||w,k;t[8]===w?k=t[9]:(k=w?(0,Q.jsx)(S,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Q.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),t[8]=w,t[9]=k);let A;t[10]===c.securityAuditRefresh?A=t[11]:(A=(0,Q.jsx)(`span`,{className:`ml-1.5`,children:c.securityAuditRefresh}),t[10]=c.securityAuditRefresh,t[11]=A);let j;t[12]!==D||t[13]!==O||t[14]!==k||t[15]!==A?(j=(0,Q.jsxs)(x,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:D,children:[k,A]}),t[12]=D,t[13]=O,t[14]=k,t[15]=A,t[16]=j):j=t[16];let M;t[17]!==c.securityAuditSubtitle||t[18]!==c.securityAuditTitle||t[19]!==j?(M=(0,Q.jsx)(ie,{icon:T,title:c.securityAuditTitle,subtitle:c.securityAuditSubtitle,trailing:j}),t[17]=c.securityAuditSubtitle,t[18]=c.securityAuditTitle,t[19]=j,t[20]=M):M=t[20];let N;t[21]===c.securityAuditSavedConfigHint?N=t[22]:(N=(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:c.securityAuditSavedConfigHint}),t[21]=c.securityAuditSavedConfigHint,t[22]=N);let F;t[23]!==b||t[24]!==c.securityAuditLoadError?(F=b?(0,Q.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[c.securityAuditLoadError,`: `,b]}):null,t[23]=b,t[24]=c.securityAuditLoadError,t[25]=F):F=t[25];let I;t[26]!==y||t[27]!==b||t[28]!==w?(I=!b&&w&&!y?(0,Q.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,Q.jsx)(C,{className:`h-11 w-full rounded-lg`}),(0,Q.jsx)(C,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=y,t[27]=b,t[28]=w,t[29]=I):I=t[29];let L;t[30]!==y||t[31]!==c?(L=y?(0,Q.jsx)(je,{g:c,audit:y}):null,t[30]=y,t[31]=c,t[32]=L):L=t[32];let R;return t[33]!==M||t[34]!==N||t[35]!==F||t[36]!==I||t[37]!==L?(R=(0,Q.jsxs)(ae,{children:[M,N,F,I,L]}),t[33]=M,t[34]=N,t[35]=F,t[36]=I,t[37]=L,t[38]=R):R=t[38],R}function ke(){return De()}function Ae(e){return e.language}function je(e){let t=(0,W.c)(40),{g:n,audit:r}=e,i,a,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=Fe(n,r.status,r.findings),d=`space-y-4`,l=o(`rounded-lg px-3 py-2.5 text-sm`,a.bannerClass),u=`status`,c=`flex items-start gap-2`,i=a.icon,s=o(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(i=t[3],a=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==i||t[11]!==s?(f=(0,Q.jsx)(i,{className:s,"aria-hidden":!0}),t[10]=i,t[11]=s,t[12]=f):f=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,Q.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,Q.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==c||t[21]!==f||t[22]!==h?(g=(0,Q.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,Q.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,Q.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,Q.jsx)(Ne,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,Q.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,Q.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(Me)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,Q.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function Me(e){return(0,Q.jsx)(`li`,{className:`font-mono`,children:e},e)}function Ne(e){let t=(0,W.c)(31),{g:n,finding:r}=e,i,a,s,c;if(t[0]!==r.severity){let e=Pe(r.severity);c=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,s=`flex items-start gap-2`,i=e.icon,a=o(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=s,t[4]=c}else i=t[1],a=t[2],s=t[3],c=t[4];let l;t[5]!==i||t[6]!==a?(l=(0,Q.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,Q.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,Q.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==s||t[26]!==l?(g=(0,Q.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,Q.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function Pe(e){switch(e){case`critical`:return{icon:F,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:_,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:z,iconClass:`text-fg-muted`}}}function Fe(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:F,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`bg-red-50 text-red-950 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:_,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`bg-amber-50 text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:z,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`bg-surface-base/55 text-fg`}:{icon:T,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`bg-emerald-50 text-emerald-950 dark:bg-emerald-950/40 dark:text-emerald-100`}}var Ie=new Set([`security`,`advanced`]);function Le(e,t){return t===`advanced`?!0:!Ie.has(e)}function Re(e,t){return e.filter(e=>Le(e,t))}function ze(){return`network`}function Be(e,t){let n=(0,W.c)(5),r=g(Ve),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{Le(e,r)||t(ze())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,U.useEffect)(i,a)}function Ve(e){return e.mode}function $(){return o(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,w,`dark:border-edge`)}var He=[`network`,`access`,`updates`,`security`,`advanced`],Ue={network:v,access:M,updates:P,security:E,advanced:b};function We(e){return e&&He.includes(e)?e:`network`}function Ge(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function Ke(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function qe(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var Je={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Ye(){let e=c(e=>e.baseUrl),t=l(e=>e.language),n=a(t),r=n.gatewaySettings,[s,u]=i(),f=g(e=>e.mode),p=f===`advanced`,_=We(s.get(`tab`)),v=(0,U.useMemo)(()=>Re(He,f),[f]),b=(0,U.useCallback)(e=>{u(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[u]);Be(_,b);let C=c(e=>e.conversationId),w=c(e=>e.tokenExpired),T=c(e=>e.openTokenDialog),E=!!C,[D,k]=(0,U.useReducer)(qe,{form:null,baseline:null,appliedBaseline:null}),M=D.form,P=D.baseline,I=D.appliedBaseline,[R,z]=(0,U.useReducer)(te,Je),{saving:H,error:ie,auditRefreshToken:ae,restarting:W,restartConfirmOpen:se}=R,G=(0,U.useRef)(!1),K=(0,U.useRef)(null),q=(0,U.useRef)(!1),{data:J,error:Y,isLoading:le,mutate:fe}=m(E),pe=d(E&&M?[`gateway-cors-origin-candidates`,M.port]:null,([,e])=>de(e),{revalidateOnFocus:!1}),X=(0,U.useMemo)(()=>J?.payload?.config===void 0?null:structuredClone(ye(J.payload.config)),[J]);E?X!==null&&(q.current||(q.current=!0,k({type:`init-applied`,value:X})),!G.current&&K.current!==X&&(K.current=X,k({type:`sync`,value:X}),z({type:`patch`,patch:{saveOk:!1}}))):(K.current!==null||q.current)&&(K.current=null,q.current=!1,k({type:`reset`}),G.current=!1);let me=!!(E&&le&&J===void 0&&!Y),Z=Y instanceof Error?Y.message:Y?String(Y):null,he=(0,U.useMemo)(()=>!M||!P?!1:JSON.stringify(M)!==JSON.stringify(P),[M,P]),ge=(0,U.useMemo)(()=>!P||!I?!1:ue(I,P),[I,P]),_e=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),be=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Ce=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),we=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Te=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Ee=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,port:e})})},[]),De=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),ke=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Ae=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),je=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Me=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Ne=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Pe=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Fe=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ie=(0,U.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),Le=(0,U.useCallback)(async()=>{if(!M||H)return;let e=ve(M);if(e){z({type:`patch`,patch:{error:e}});return}z({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await xe(M),G.current=!1,k({type:`saved`,value:M}),z({type:`patch`,patch:{saveOk:!0,auditRefreshToken:ae+1}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:r.saveError}})}finally{z({type:`patch`,patch:{saving:!1}})}},[M,H,r.saveError]),ze=(0,U.useCallback)(()=>{P&&(G.current=!1,k({type:`discard`}),z({type:`patch`,patch:{error:null,saveOk:!1}}))},[P]),Ve=h(r),Ue=(0,U.useCallback)(async()=>{if(!W){z({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await j();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):z({type:`patch`,patch:{error:e.message||r.restartGatewayFailed}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{z({type:`patch`,patch:{restarting:!1}})}}},[W,r.restartGatewayFailed]);return E?me?(0,Q.jsx)(re,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Q.jsx)(O,{sections:3})}):M?(0,Q.jsxs)(re,{gap:`gap-6`,children:[(0,Q.jsx)(ne,{title:n.settingsSections.gateway,docsLink:N(t,`gateway`),docsLabel:r.docsLink,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(x,{type:`button`,variant:`secondary`,disabled:!he||H,onClick:ze,children:r.discard}),(0,Q.jsx)(x,{type:`button`,variant:`primary`,disabled:!he||H,onClick:()=>void Le(),children:H?r.saving:r.save})]})}),w?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-red-50 px-4 py-3 dark:bg-red-950/40`,role:`alert`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(F,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:r.tokenExpired})]}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(x,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>T(),children:r.updateToken})})]}):null,ie?(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ie}):null,ge?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-amber-50 px-3 py-2 dark:bg-amber-950/40`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:r.restartHint}),(0,Q.jsxs)(x,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:W,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[W?(0,Q.jsx)(S,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(ee,{className:`size-3.5`}),r.restartGatewayButton]})]}):null,(0,Q.jsx)(A,{open:se,title:r.restartGatewayButton,description:r.restartGatewayConfirm,confirmLabel:r.restartGatewayButton,cancelLabel:r.discard,destructive:!0,onConfirm:()=>void Ue(),onCancel:()=>z({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,Q.jsx)(Oe,{enabled:E,refreshToken:ae}),(0,Q.jsx)(Xe,{g:r,activeTab:_,visibleTabs:v,onChange:b}),(0,Q.jsxs)(Ze,{g:r,id:`network`,activeTab:_,children:[(0,Q.jsxs)(`section`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`zh`?`当前服务连接`:`Current service connection`}),(0,Q.jsx)(`p`,{className:`break-all text-sm text-fg-muted`,children:e}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:r.retry}),(0,Q.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>T(),children:r.updateToken}),(0,Q.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:r.restartGatewayButton})]})]}),(0,Q.jsx)(Se,{value:M.outboundProxy,g:r,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,outboundProxy:e})})}}),(0,Q.jsxs)(y,{title:t===`zh`?`服务监听配置`:`Service listener configuration`,summary:`${M.bind} · ${M.port}`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:r.bindMode}),(0,Q.jsxs)(L,{id:`gateway-bind-mode`,className:$(),value:M.bind,onChange:e=>we(e.target.value),children:[(0,Q.jsx)(B,{value:`loopback`,children:r.bindLoopback}),p?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(B,{value:`lan`,children:r.bindLan}),(0,Q.jsx)(B,{value:`auto`,children:r.bindAuto}),(0,Q.jsx)(B,{value:`custom`,children:r.bindCustom}),(0,Q.jsx)(B,{value:`tailnet`,children:r.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:r.customBindHost}),(0,Q.jsx)(`input`,{id:`gateway-custom-bind-host`,className:o($(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>Te(e.target.value),placeholder:r.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:r.listenPort}),(0,Q.jsx)(V,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:o($(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);Ee(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]})]}),(0,Q.jsx)(oe,{children:(0,Q.jsx)(nt,{g:r,origins:M.corsOrigins,candidates:pe.data??[],onChange:Ce})})]})]}),(0,Q.jsxs)(Ze,{g:r,id:`access`,activeTab:_,children:[M.auth.mode===`none`?(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:r.authModeNone}):null,(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:r.authMode}),(0,Q.jsxs)(L,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>_e({mode:e.target.value}),className:$(),children:[(0,Q.jsx)(B,{value:`token`,children:r.authModeToken}),(0,Q.jsx)(B,{value:`password`,children:r.authModePassword}),p||M.auth.mode===`trusted-proxy`||M.auth.mode===`none`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(B,{value:`trusted-proxy`,children:r.authModeTrustedProxy}),(0,Q.jsx)(B,{value:`none`,children:r.authModeNoneLabel})]}):null]})]}),(0,Q.jsx)(oe,{children:M.auth.mode===`trusted-proxy`?(0,Q.jsx)($e,{g:r,form:M,onTrustedProxyChange:Ne,onTrustedProxiesChange:Me,onAllowRealIpFallbackChange:Fe}):null}),M.auth.mode===`token`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ot,{id:`gateway-access-token`,label:r.accessToken,help:r.tokenHelp,placeholder:r.tokenPlaceholder,value:M.auth.token,labels:Ve,reveal:()=>ce(`token`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>_e({token:e})}),(0,Q.jsx)(x,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>T(),children:r.changeToken})]}):null,M.auth.mode===`password`?(0,Q.jsx)(ot,{id:`gateway-auth-password`,label:r.authPassword,help:r.authPasswordHelp,placeholder:r.authPasswordPlaceholder,value:M.auth.password,labels:Ve,reveal:()=>ce(`password`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>_e({password:e})}):null,(0,Q.jsx)(oe,{children:M.auth.mode===`none`?null:(0,Q.jsx)(at,{g:r,rateLimit:M.auth.rateLimit,onChange:De})})]}),(0,Q.jsxs)(Ze,{g:r,id:`updates`,activeTab:_,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:r.updateChannel}),(0,Q.jsxs)(L,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>be(e.target.value),className:$(),children:[(0,Q.jsx)(B,{value:`stable`,children:r.channelStable}),p||M.updateChannel===`beta`?(0,Q.jsx)(B,{value:`beta`,children:r.channelBeta}):null,p||M.updateChannel===`dev`?(0,Q.jsx)(B,{value:`dev`,children:r.channelDev}):null]})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.updateAutoSection}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:r.updateCheckOnStart}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateCheckOnStartHint})]})]}),(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:r.updateAutoEnabled}),(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateAutoEnabledHint})]})]}),(0,Q.jsx)(oe,{children:(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:r.updateAutoStableDelayHours}),(0,Q.jsx)(V,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:$(),value:M.updateAutoStableDelayHours,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableDelayHoursHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:r.updateAutoStableJitterHours}),(0,Q.jsx)(V,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:$(),value:M.updateAutoStableJitterHours,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableJitterHoursHint})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:r.updateAutoBetaCheckIntervalHours}),(0,Q.jsx)(V,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:$(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoBetaCheckIntervalHoursHint})]})]})})]})]}),(0,Q.jsx)(Ze,{g:r,id:`security`,activeTab:_,children:(0,Q.jsx)(Qe,{g:r,form:M,onSecurityStrictChange:Pe,onDangerouslyAllowHostHeaderOriginFallbackChange:Ie})}),(0,Q.jsx)(Ze,{g:r,id:`advanced`,activeTab:_,children:(0,Q.jsx)(et,{g:r,form:M,onDeferModeChange:ke,onDeferIdsChange:Ae,onSkipIdsChange:je})})]}):(0,Q.jsxs)(re,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ie??Z??r.loadError}),(0,Q.jsx)(x,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:r.retry})]}):(0,Q.jsxs)(re,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Q.jsx)(ne,{title:n.settingsSections.gateway}),(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function Xe(e){let t=(0,W.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:Ge(n,e),icon:Ue[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,Q.jsx)(R,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Ze(e){let t=(0,W.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=Ge(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Ke(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,Q.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,Q.jsx)(H,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,showHeading:!1,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Qe(e){let t=(0,W.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,Q.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,Q.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,Q.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,Q.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function $e(e){let t=(0,W.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=o($(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,Q.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,Q.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==c.requiredHeaders?(_=(0,Q.jsx)(tt,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==c.allowUsers?(y=(0,Q.jsx)(tt,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,Q.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,Q.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,Q.jsx)(tt,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,Q.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,Q.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,Q.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,Q.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function et(e){let t=(0,W.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:a,onSkipIdsChange:o}=e,s;t[0]===n.channelConnectDeferMode?s=t[1]:(s=(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=s);let c=r.channelConnectDeferMode,l;t[2]===i?l=t[3]:(l=e=>i(e.target.value),t[2]=i,t[3]=l);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=$(),t[4]=u):u=t[4];let d;t[5]===n.channelConnectDeferModeAuto?d=t[6]:(d=(0,Q.jsx)(B,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=d);let f;t[7]===n.channelConnectDeferModeOff?f=t[8]:(f=(0,Q.jsx)(B,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=f);let p;t[9]===n.channelConnectDeferModeExplicit?p=t[10]:(p=(0,Q.jsx)(B,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=p);let m;t[11]!==r.channelConnectDeferMode||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,Q.jsxs)(L,{id:`gateway-channel-defer-mode`,value:c,onChange:l,className:u,children:[d,f,p]}),t[11]=r.channelConnectDeferMode,t[12]=l,t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;t[17]===n.channelConnectDeferModeHint?h=t[18]:(h=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=h);let g;t[19]!==s||t[20]!==m||t[21]!==h?(g=(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[s,m,h]}),t[19]=s,t[20]=m,t[21]=h,t[22]=g):g=t[22];let _;t[23]!==r.channelConnectDeferIds||t[24]!==r.channelConnectDeferMode||t[25]!==n.channelConnectDeferIds||t[26]!==n.channelConnectDeferIdsHint||t[27]!==n.channelIdListEmpty||t[28]!==n.channelIdListPlaceholder||t[29]!==a?(_=r.channelConnectDeferMode===`explicit`?(0,Q.jsx)(tt,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:a}):null,t[23]=r.channelConnectDeferIds,t[24]=r.channelConnectDeferMode,t[25]=n.channelConnectDeferIds,t[26]=n.channelConnectDeferIdsHint,t[27]=n.channelIdListEmpty,t[28]=n.channelIdListPlaceholder,t[29]=a,t[30]=_):_=t[30];let v;t[31]!==r.channelConnectDeferMode||t[32]!==r.channelConnectDeferSkipIds||t[33]!==n.channelConnectDeferSkipIds||t[34]!==n.channelConnectDeferSkipIdsHint||t[35]!==n.channelIdListEmpty||t[36]!==n.channelIdListPlaceholder||t[37]!==o?(v=r.channelConnectDeferMode===`off`?null:(0,Q.jsx)(tt,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:o}),t[31]=r.channelConnectDeferMode,t[32]=r.channelConnectDeferSkipIds,t[33]=n.channelConnectDeferSkipIds,t[34]=n.channelConnectDeferSkipIdsHint,t[35]=n.channelIdListEmpty,t[36]=n.channelIdListPlaceholder,t[37]=o,t[38]=v):v=t[38];let y;return t[39]!==g||t[40]!==_||t[41]!==v?(y=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[g,_,v]}),t[39]=g,t[40]=_,t[41]=v,t[42]=y):y=t[42],y}function tt(e){let t=(0,W.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==l||t[10]!==s?(h=s.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,Q.jsx)(`button`,{type:`button`,className:o(`text-fg-muted hover:text-fg`,k.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=o($(),`font-mono text-xs`),t[12]=g):g=t[12];let _=s.length>=c,v;t[13]===f?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=v);let y;t[15]!==a||t[16]!==_||t[17]!==v?(y=(0,Q.jsx)(`input`,{className:g,placeholder:a,disabled:_,onKeyDown:v}),t[15]=a,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(b=(0,Q.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[p,m,h,y,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=b):b=t[24],b}function nt(e){let t=(0,W.c)(36),{g:n,origins:r,candidates:i,onChange:a}=e,o;t[0]===r?o=t[1]:(o=r.includes(`*`),t[0]=r,t[1]=o);let s=o,c,l,u,d,f,p,m,h,g;if(t[2]!==i||t[3]!==n.corsAddDetectedOrigins||t[4]!==n.corsDetectedOrigins||t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==a||t[10]!==r){let e;t[20]===r?e=t[21]:(e=e=>!r.includes(e.url),t[20]=r,t[21]=e);let o=i.filter(e);c=tt,l=n.corsOrigins,u=n.corsOriginsHint,d=n.corsOriginsEmpty,f=n.corsOriginsPlaceholder,p=r,m=128,h=a,g=o.length>0?(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.corsDetectedOrigins}),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(it)}),(0,Q.jsx)(x,{type:`button`,variant:`secondary`,className:`mt-2 text-xs`,onClick:()=>a([...r,...o.map(rt)]),children:n.corsAddDetectedOrigins})]}):null,t[2]=i,t[3]=n.corsAddDetectedOrigins,t[4]=n.corsDetectedOrigins,t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=a,t[10]=r,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h,t[19]=g}else c=t[11],l=t[12],u=t[13],d=t[14],f=t[15],p=t[16],m=t[17],h=t[18],g=t[19];let _;t[22]!==n.corsOriginsWildcardWarning||t[23]!==s?(_=s?(0,Q.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[22]=n.corsOriginsWildcardWarning,t[23]=s,t[24]=_):_=t[24];let v;return t[25]!==c||t[26]!==_||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==h||t[34]!==g?(v=(0,Q.jsxs)(c,{title:l,hint:u,emptyText:d,placeholder:f,values:p,maxItems:m,onChange:h,children:[g,_]}),t[25]=c,t[26]=_,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m,t[33]=h,t[34]=g,t[35]=v):v=t[35],v}function rt(e){return e.url}function it(e){return(0,Q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e.url,` · `,e.interfaceName]},e.url)}function at(e){let t=(0,W.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Q.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,Q.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=$(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,Q.jsx)(V,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,Q.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=$(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,Q.jsx)(V,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,Q.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,Q.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=$(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,Q.jsx)(V,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,Q.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function ot(e){let t=(0,W.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,Q.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,Q.jsx)(I,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{Ye as GatewaySettingsPanel};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,g as o}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./external-link-DjqjBmc3.js";import{M as l}from"./markdown-view-PrKvVpRh.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-CaeL_miw.js";import{t as p}from"./cn-0WouolD0.js";import{n as m}from"./locale-store-CE7L6MlS.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{s as S}from"./tasks-PuIUgF9L.js";import{$c as C,An as w,Cs as T,Gc as E,Hc as D,Hi as O,Ic as k,Kd as A,Lu as j,Mi as M,Mn as N,Nn as P,Qc as F,Ss as I,Ts as L,Ui as ee,Ul as R,Uo as te,Vs as z,Wc as B,Zc as V,Zl as ne,aa as H,af as U,al as W,au as G,ea as re,fl as ie,if as ae,il as oe,io as se,jn as ce,lf as le,nl as ue,pd as K,qc as q,r as de,rl as fe,sf as pe,sl as me,tl as he,ws as J,xu as ge}from"./index-CKdOZoVu.js";import{n as _e}from"./tab-completion-input-CxtEp0aP.js";import{n as Y,t as X}from"./task-expandable-content-DTEVoNrM.js";var Z=n(),Q=e(t(),1);function ve(e,t){let[n,r]=(0,Q.useState)(null),[i,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(null),c=(0,Q.useRef)(0),l=(0,Q.useCallback)(async()=>{let t=++c.current;s(null);try{let n=await V(e);t===c.current&&r(n)}catch(e){t===c.current&&s(e instanceof Error?e.message:String(e))}finally{t===c.current&&a(!1)}},[e]);return(0,Q.useEffect)(()=>(l(),()=>{c.current++}),[l,t]),(0,Q.useEffect)(()=>{let e,t=1/0,n=n=>{let r=Date.now()+n;r>=t||(window.clearTimeout(e),t=r,e=window.setTimeout(()=>{e=void 0,t=1/0,l()},n))},r=()=>n(100),i=()=>n(750),a=()=>{document.visibilityState===`visible`&&r()},o=[`task-changed-v2`,`task-updated`,`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`,`home-advisor-updated`,`gateway-realtime-connected`,`realtime-gap`,`focus`],s=[`session-updated`,`session-transcript-updated`];return o.forEach(e=>window.addEventListener(e,r)),s.forEach(e=>window.addEventListener(e,i)),document.addEventListener(`visibilitychange`,a),()=>{o.forEach(e=>window.removeEventListener(e,r)),s.forEach(e=>window.removeEventListener(e,i)),document.removeEventListener(`visibilitychange`,a),window.clearTimeout(e)}},[l]),{home:n,loading:i,loadError:o,setLoadError:s,load:l}}var $=r(),ye=12e3;function be(e){let t=(0,Z.c)(107),{variant:n,inputId:r,inputRef:i,intent:a,labels:o,attachments:s,isDragging:c,attachmentBusy:l,attachmentsFull:u,voice:d,chat:f,cancelAction:m,onIntentChange:h,onPickFiles:g,onRemoveAttachment:_,onPaste:v,onDragOver:y,onDragLeave:b,onDrop:x,onSubmit:S}=e,C=n===`inline`,w;t[0]!==s||t[1]!==a?(w=!!a.trim()||s.length>0,t[0]=s,t[1]=a,t[2]=w):w=t[2];let T=w,E=d.voiceActive&&d.phase!==`error`,O;t[3]!==S||t[4]!==d.voiceActive?(O=e=>{if(d.voiceActive){e.preventDefault();return}S(e)},t[3]=S,t[4]=d.voiceActive,t[5]=O):O=t[5];let k=C?`mx-auto mt-6 w-full overflow-hidden rounded-xl border border-edge bg-surface-base p-2 text-left shadow-surface transition-colors focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/15 sm:mt-8`:`flex min-h-0 flex-1 flex-col`,A;t[6]===k?A=t[7]:(A=p(`relative`,k),t[6]=k,t[7]=A);let j;t[8]!==C||t[9]!==c||t[10]!==o.dropFiles?(j=c?(0,$.jsx)(`div`,{className:p(`pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-accent-soft/90 text-sm font-medium text-accent-fg backdrop-blur-[1px]`,C&&`rounded-2xl`),children:o.dropFiles}):null,t[8]=C,t[9]=c,t[10]=o.dropFiles,t[11]=j):j=t[11];let M=!C&&`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,P;t[12]===M?P=t[13]:(P=p(M),t[12]=M,t[13]=P);let F=C?`sr-only`:`mb-2 shrink-0 text-sm font-medium text-fg`,I;t[14]!==r||t[15]!==o.intentLabel||t[16]!==F?(I=(0,$.jsx)(`label`,{htmlFor:r,className:F,children:o.intentLabel}),t[14]=r,t[15]=o.intentLabel,t[16]=F,t[17]=I):I=t[17];let L;t[18]!==l||t[19]!==f||t[20]!==d.audioLevel||t[21]!==d.cancelVoiceInput||t[22]!==d.confirmVoiceInput||t[23]!==d.elapsedLabel||t[24]!==d.error||t[25]!==d.finalTranscript||t[26]!==d.partialTranscript||t[27]!==d.phase||t[28]!==d.recordedDictation||t[29]!==d.retryVoiceInput||t[30]!==d.settingsRequired||t[31]!==d.voiceActive?(L=d.voiceActive?(0,$.jsx)(N,{phase:d.phase,elapsedLabel:d.elapsedLabel,recordedDictation:d.recordedDictation,audioLevel:d.audioLevel,partialTranscript:d.partialTranscript,finalTranscript:d.finalTranscript,error:d.error,settingsRequired:d.settingsRequired,disabled:l,chat:f,onCancel:d.cancelVoiceInput,onConfirm:d.confirmVoiceInput,onRetry:d.retryVoiceInput}):null,t[18]=l,t[19]=f,t[20]=d.audioLevel,t[21]=d.cancelVoiceInput,t[22]=d.confirmVoiceInput,t[23]=d.elapsedLabel,t[24]=d.error,t[25]=d.finalTranscript,t[26]=d.partialTranscript,t[27]=d.phase,t[28]=d.recordedDictation,t[29]=d.retryVoiceInput,t[30]=d.settingsRequired,t[31]=d.voiceActive,t[32]=L):L=t[32];let te=E&&`hidden`,z=C?`min-h-24 bg-transparent px-3 py-2`:`min-h-32 flex-1 rounded-xl border border-edge bg-surface-base p-3 focus:border-accent focus:ring-2 focus:ring-accent/20`,B;t[33]!==te||t[34]!==z?(B=p(`w-full resize-none text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle`,te,z),t[33]=te,t[34]=z,t[35]=B):B=t[35];let V;t[36]===h?V=t[37]:(V=e=>h(e.target.value),t[36]=h,t[37]=V);let ne=!C,H;t[38]!==r||t[39]!==i||t[40]!==a||t[41]!==o.intentPlaceholder||t[42]!==o.intentSuggestion||t[43]!==h||t[44]!==v||t[45]!==B||t[46]!==V||t[47]!==ne?(H=(0,$.jsx)(_e,{ref:i,id:r,className:B,value:a,onChange:V,onPaste:v,suggestion:o.intentSuggestion,onAcceptSuggestion:h,onKeyDown:xe,placeholder:o.intentPlaceholder,maxLength:ye,autoFocus:ne}),t[38]=r,t[39]=i,t[40]=a,t[41]=o.intentPlaceholder,t[42]=o.intentSuggestion,t[43]=h,t[44]=v,t[45]=B,t[46]=V,t[47]=ne,t[48]=H):H=t[48];let U=C?`border-b-0 bg-transparent px-3 pb-2 pt-0`:`mt-3 border-b-0 bg-transparent px-0 pb-0`,W;t[49]!==s||t[50]!==_||t[51]!==U?(W=(0,$.jsx)(re,{attachments:s,topPadded:!1,onRemove:_,className:U}),t[49]=s,t[50]=_,t[51]=U,t[52]=W):W=t[52];let G;t[53]!==C||t[54]!==a.length||t[55]!==o.shortcut?(G=C?null:(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,$.jsx)(`span`,{children:o.shortcut}),(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[a.length.toLocaleString(),` / `,ye.toLocaleString()]})]}),t[53]=C,t[54]=a.length,t[55]=o.shortcut,t[56]=G):G=t[56];let ie;t[57]!==L||t[58]!==H||t[59]!==W||t[60]!==G||t[61]!==P||t[62]!==I?(ie=(0,$.jsxs)(`div`,{className:P,children:[I,L,H,W,G]}),t[57]=L,t[58]=H,t[59]=W,t[60]=G,t[61]=P,t[62]=I,t[63]=ie):ie=t[63];let ae=C?`border-edge-subtle px-1 pt-2`:`border-edge px-5 py-4`,oe;t[64]===ae?oe=t[65]:(oe=p(`flex shrink-0 items-center gap-2 border-t`,ae),t[64]=ae,t[65]=oe);let se=!C&&`mr-auto`,ce;t[66]===se?ce=t[67]:(ce=p(`flex items-center gap-1`,se),t[66]=se,t[67]=ce);let le=l||u,ue;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(ge,{className:`size-4`,"aria-hidden":!0}),t[68]=ue):ue=t[68];let K;t[69]!==o.attachTitle||t[70]!==g||t[71]!==le?(K=(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 rounded-lg p-0`,disabled:le,title:o.attachTitle,"aria-label":o.attachTitle,onClick:g,children:ue}),t[69]=o.attachTitle,t[70]=g,t[71]=le,t[72]=K):K=t[72];let q;t[73]!==l||t[74]!==f||t[75]!==d.startVoiceInput||t[76]!==d.voiceActive?(q=d.voiceActive?null:(0,$.jsx)(ee,{disabled:l,chat:f,onStart:d.startVoiceInput}),t[73]=l,t[74]=f,t[75]=d.startVoiceInput,t[76]=d.voiceActive,t[77]=q):q=t[77];let de;t[78]!==ce||t[79]!==K||t[80]!==q?(de=(0,$.jsxs)(`div`,{className:ce,children:[K,q]}),t[78]=ce,t[79]=K,t[80]=q,t[81]=de):de=t[81];let fe;t[82]!==m||t[83]!==C||t[84]!==o.shortcut?(fe=C?(0,$.jsx)(`span`,{className:`hidden text-[11px] text-fg-subtle sm:inline`,children:o.shortcut}):m,t[82]=m,t[83]=C,t[84]=o.shortcut,t[85]=fe):fe=t[85];let pe=C?`ml-auto h-9 rounded-lg px-3.5 text-xs`:`min-w-32`,me=!T||l||d.voiceActive,he=C?`size-3.5`:`size-4`,J;t[86]===he?J=t[87]:(J=(0,$.jsx)(R,{className:he,"aria-hidden":!0}),t[86]=he,t[87]=J);let Y;t[88]!==o.submit||t[89]!==pe||t[90]!==me||t[91]!==J?(Y=(0,$.jsxs)(D,{type:`submit`,variant:`primary`,className:pe,disabled:me,children:[J,o.submit]}),t[88]=o.submit,t[89]=pe,t[90]=me,t[91]=J,t[92]=Y):Y=t[92];let X;t[93]!==oe||t[94]!==de||t[95]!==fe||t[96]!==Y?(X=(0,$.jsxs)(`div`,{className:oe,children:[de,fe,Y]}),t[93]=oe,t[94]=de,t[95]=fe,t[96]=Y,t[97]=X):X=t[97];let Q;return t[98]!==b||t[99]!==y||t[100]!==x||t[101]!==O||t[102]!==ie||t[103]!==X||t[104]!==A||t[105]!==j?(Q=(0,$.jsxs)(`form`,{onSubmit:O,onDragOver:y,onDragLeave:b,onDrop:x,className:A,children:[j,ie,X]}),t[98]=b,t[99]=y,t[100]=x,t[101]=O,t[102]=ie,t[103]=X,t[104]=A,t[105]=j,t[106]=Q):Q=t[106],Q}function xe(e){e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())}function Se(e){let t=(0,Z.c)(4),{label:n,onClick:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==r?(a=(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-h-9 items-center gap-1.5 rounded-lg px-2 text-xs font-medium text-fg-muted transition-colors duration-150 hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:r,children:[i,n]}),t[1]=n,t[2]=r,t[3]=a):a=t[3],a}function Ce(e){let t=(0,Z.c)(65),{opportunity:n,copy:r,onOpenHistory:i}=e,a,o,s,c,l,u;if(t[0]!==r.aiLabel||t[1]!==r.automationAction||t[2]!==r.automationHint||t[3]!==r.history||t[4]!==r.minutes||t[5]!==r.needsSetup||t[6]!==r.why||t[7]!==i||t[8]!==n.capabilities||t[9]!==n.continuation||t[10]!==n.estimatedMinutes||t[11]!==n.outcome||t[12]!==n.rationale||t[13]!==n.title){let e=n.capabilities.filter(Te),d;t[20]===r.aiLabel?d=t[21]:(d=(0,$.jsx)(`span`,{children:r.aiLabel}),t[20]=r.aiLabel,t[21]=d);let f;t[22]!==r.minutes||t[23]!==n.estimatedMinutes?(f=n.estimatedMinutes?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,$.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),n.estimatedMinutes,` `,r.minutes]}):null,t[22]=r.minutes,t[23]=n.estimatedMinutes,t[24]=f):f=t[24];let p;t[25]!==d||t[26]!==f?(p=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[d,f]}),t[25]=d,t[26]=f,t[27]=p):p=t[27];let m;t[28]!==r.history||t[29]!==i?(m=(0,$.jsx)(Se,{label:r.history,onClick:i}),t[28]=r.history,t[29]=i,t[30]=m):m=t[30],t[31]!==m||t[32]!==p?(a=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[p,m]}),t[31]=m,t[32]=p,t[33]=a):a=t[33],t[34]===n.title?o=t[35]:(o=(0,$.jsx)(`h3`,{className:`mt-3 text-xl font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[34]=n.title,t[35]=o),t[36]===n.outcome?s=t[37]:(s=(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.outcome}),t[36]=n.outcome,t[37]=s);let h;t[38]===r.why?h=t[39]:(h=(0,$.jsxs)(`span`,{className:`font-medium text-fg`,children:[r.why,`:`]}),t[38]=r.why,t[39]=h),t[40]!==n.rationale||t[41]!==h?(c=(0,$.jsxs)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:[h,n.rationale]}),t[40]=n.rationale,t[41]=h,t[42]=c):c=t[42],t[43]!==r.automationAction||t[44]!==r.automationHint||t[45]!==n.continuation?(l=n.continuation?.kind===`automation`?(0,$.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 rounded-xl border border-edge bg-surface-subtle p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:r.automationHint}),(0,$.jsx)(`a`,{href:`#${n.continuation.href}`,className:`inline-flex min-h-11 shrink-0 items-center rounded-lg px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.automationAction})]}):null,t[43]=r.automationAction,t[44]=r.automationHint,t[45]=n.continuation,t[46]=l):l=t[46],u=e.length>0?(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,"aria-label":r.needsSetup,children:e.map(e=>(0,$.jsxs)(`a`,{href:`#${e.recoveryPath??`/settings`}`,className:`rounded-full border border-accent/25 bg-accent-soft px-2.5 py-1 text-xs text-accent hover:border-accent/50`,children:[r.needsSetup,` · `,e.capability]},`${e.kind}:${e.capability}`))}):null,t[0]=r.aiLabel,t[1]=r.automationAction,t[2]=r.automationHint,t[3]=r.history,t[4]=r.minutes,t[5]=r.needsSetup,t[6]=r.why,t[7]=i,t[8]=n.capabilities,t[9]=n.continuation,t[10]=n.estimatedMinutes,t[11]=n.outcome,t[12]=n.rationale,t[13]=n.title,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l,t[19]=u}else a=t[14],o=t[15],s=t[16],c=t[17],l=t[18],u=t[19];let d;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(pe,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[47]=d):d=t[47];let f;t[48]===r.evidence?f=t[49]:(f=(0,$.jsxs)(`summary`,{className:`flex min-h-9 cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.evidence,d]}),t[48]=r.evidence,t[49]=f);let p;t[50]===n.evidence?p=t[51]:(p=n.evidence.map(we),t[50]=n.evidence,t[51]=p);let m;t[52]===p?m=t[53]:(m=(0,$.jsx)(`ul`,{className:`mt-2 space-y-2 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:p}),t[52]=p,t[53]=m);let h;t[54]!==m||t[55]!==f?(h=(0,$.jsxs)(`details`,{className:`mt-4 group`,children:[f,m]}),t[54]=m,t[55]=f,t[56]=h):h=t[56];let g;return t[57]!==a||t[58]!==h||t[59]!==o||t[60]!==s||t[61]!==c||t[62]!==l||t[63]!==u?(g=(0,$.jsxs)($.Fragment,{children:[a,o,s,c,l,u,h]}),t[57]=a,t[58]=h,t[59]=o,t[60]=s,t[61]=c,t[62]=l,t[63]=u,t[64]=g):g=t[64],g}function we(e){return(0,$.jsx)(`li`,{children:e.href?(0,$.jsx)(`a`,{href:`#${e.href}`,className:`hover:text-accent hover:underline`,children:e.observation}):e.observation},e.id)}function Te(e){return e.readiness!==`ready`}function Ee(e){let t=(0,Z.c)(130),{advisor:n,copy:r,busy:i,onRefresh:a,onAction:o,onFeedback:c,onClarification:l,onOpenHistory:u,preflight:d,receipt:f}=e,[p,m]=(0,Q.useState)(),h;t[0]!==n.alternatives||t[1]!==n.primary||t[2]!==n.state?(h=n.state===`ready`?[n.primary,...n.alternatives]:[],t[0]=n.alternatives,t[1]=n.primary,t[2]=n.state,t[3]=h):h=t[3];let g=h,_;t[4]!==g||t[5]!==p?(_=g.find(e=>e.id===p)??g[0],t[4]=g,t[5]=p,t[6]=_):_=t[6];let v=_,y;t[7]===g[0]?.id?y=t[8]:(y=()=>m(g[0]?.id),t[7]=g[0]?.id,t[8]=y);let b=g[0]?.id,x;if(t[9]!==n.state||t[10]!==b?(x=[n.state,b],t[9]=n.state,t[10]=b,t[11]=x):x=t[11],(0,Q.useEffect)(y,x),n.state===`disabled`)return null;if(f){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(s,{className:`size-5 shrink-0 text-success`,"aria-hidden":!0}),t[12]=e):e=t[12];let n;t[13]===f.title?n=t[14]:(n=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:f.title}),t[13]=f.title,t[14]=n);let i;t[15]===f.detail?i=t[16]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:f.detail}),t[15]=f.detail,t[16]=i);let a;t[17]!==n||t[18]!==i?(a=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[n,i]}),t[17]=n,t[18]=i,t[19]=a):a=t[19];let o;t[20]!==r.history||t[21]!==u?(o=(0,$.jsx)(Se,{label:r.history,onClick:u}),t[20]=r.history,t[21]=u,t[22]=o):o=t[22];let c=`#${f.href}`,l;t[23]!==r.viewProgress||t[24]!==c?(l=(0,$.jsx)(D,{asChild:!0,variant:`secondary`,className:`min-h-10 text-xs`,children:(0,$.jsx)(`a`,{href:c,children:r.viewProgress})}),t[23]=r.viewProgress,t[24]=c,t[25]=l):l=t[25];let d;t[26]!==o||t[27]!==l?(d=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[o,l]}),t[26]=o,t[27]=l,t[28]=d):d=t[28];let p;return t[29]!==d||t[30]!==a?(p=(0,$.jsx)(`section`,{className:`mt-7 rounded-2xl border border-success/25 bg-success-soft px-5 py-4`,role:`status`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[e,a,d]})}),t[29]=d,t[30]=a,t[31]=p):p=t[31],p}if(n.state===`quiet`||n.state===`refreshing`)return null;if(n.state===`clarification`){let e;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),t[32]=e):e=t[32];let i;t[33]===r.aiLabel?i=t[34]:(i=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-accent`,children:[e,r.aiLabel]}),t[33]=r.aiLabel,t[34]=i);let a;t[35]!==r.history||t[36]!==u?(a=(0,$.jsx)(Se,{label:r.history,onClick:u}),t[35]=r.history,t[36]=u,t[37]=a):a=t[37];let o;t[38]!==i||t[39]!==a?(o=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[i,a]}),t[38]=i,t[39]=a,t[40]=o):o=t[40];let s;t[41]===n.question.question?s=t[42]:(s=(0,$.jsx)(`h3`,{id:`home-advisor-question`,className:`mt-3 text-lg font-semibold text-fg`,children:n.question.question}),t[41]=n.question.question,t[42]=s);let c;if(t[43]!==n.question.options||t[44]!==n.question.question||t[45]!==l){let e;t[47]!==n.question.question||t[48]!==l?(e=e=>(0,$.jsx)(D,{type:`button`,variant:`secondary`,className:`min-h-11`,onClick:()=>l(n.question.question,e.label),children:e.label},e.id),t[47]=n.question.question,t[48]=l,t[49]=e):e=t[49],c=n.question.options.map(e),t[43]=n.question.options,t[44]=n.question.question,t[45]=l,t[46]=c}else c=t[46];let d;t[50]===c?d=t[51]:(d=(0,$.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:c}),t[50]=c,t[51]=d);let f;return t[52]!==s||t[53]!==d||t[54]!==o?(f=(0,$.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base px-5 py-5`,"aria-labelledby":`home-advisor-question`,children:[o,s,d]}),t[52]=s,t[53]=d,t[54]=o,t[55]=f):f=t[55],f}if(!v)return null;let S=d?.opportunityId===v.id?d.value:void 0,C;t[56]!==n.stale||t[57]!==r.refreshing?(C=n.stale?(0,$.jsxs)(`p`,{className:`mb-3 inline-flex items-center gap-2 text-xs text-accent`,children:[(0,$.jsx)(G,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.refreshing]}):null,t[56]=n.stale,t[57]=r.refreshing,t[58]=C):C=t[58];let w;t[59]!==r||t[60]!==u||t[61]!==v?(w=(0,$.jsx)(Ce,{opportunity:v,copy:r,onOpenHistory:u}),t[59]=r,t[60]=u,t[61]=v,t[62]=w):w=t[62];let T;t[63]!==i||t[64]!==r.configure||t[65]!==r.degradedStart||t[66]!==r.setupHint||t[67]!==r.setupTitle||t[68]!==o||t[69]!==v||t[70]!==S?(T=S?.state===`needs_setup`?(0,$.jsx)(`div`,{className:`mt-5 rounded-xl border border-accent/25 bg-accent-soft/40 p-4`,role:`alert`,"aria-live":`polite`,children:(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(ne,{className:`mt-0.5 size-4 shrink-0 text-accent`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:r.setupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r.setupHint}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:S.blockers.map(De)}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[S.recoveryActions.map(e=>(0,$.jsxs)(`a`,{href:`#${e.href}`,className:`inline-flex min-h-11 items-center rounded-lg border border-accent/30 px-3 text-xs font-medium text-accent hover:bg-accent-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[r.configure,` · `,e.capability]},e.capability)),S.degradedAction?(0,$.jsx)(D,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`degraded_start`),children:r.degradedStart}):null]})]})]})}):null,t[63]=i,t[64]=r.configure,t[65]=r.degradedStart,t[66]=r.setupHint,t[67]=r.setupTitle,t[68]=o,t[69]=v,t[70]=S,t[71]=T):T=t[71];let E;t[72]!==i||t[73]!==r.start||t[74]!==o||t[75]!==v?(E=v.actions.canStart?(0,$.jsxs)(D,{type:`button`,variant:`primary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`start`),children:[(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0}),r.start]}):null,t[72]=i,t[73]=r.start,t[74]=o,t[75]=v,t[76]=E):E=t[76];let O;t[77]!==i||t[78]!==r.discuss||t[79]!==o||t[80]!==v?(O=v.actions.canDiscuss?(0,$.jsxs)(D,{type:`button`,variant:`secondary`,className:`min-h-11`,disabled:i,onClick:()=>o(v,`discuss`),children:[(0,$.jsx)(j,{className:`size-4`,"aria-hidden":!0}),r.discuss]}):null,t[77]=i,t[78]=r.discuss,t[79]=o,t[80]=v,t[81]=O):O=t[81];let k;t[82]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(G,{className:`size-4`,"aria-hidden":!0}),t[82]=k):k=t[82];let A;t[83]!==i||t[84]!==r.refresh||t[85]!==a?(A=(0,$.jsxs)(D,{type:`button`,variant:`ghost`,className:`min-h-11`,disabled:i,onClick:a,title:r.refresh,children:[k,r.refresh]}),t[83]=i,t[84]=r.refresh,t[85]=a,t[86]=A):A=t[86];let M;t[87]===r.feedback?M=t[88]:(M=(0,$.jsx)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center rounded-lg px-3 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:r.feedback}),t[87]=r.feedback,t[88]=M);let N;t[89]===r.alreadyDone?N=t[90]:(N=[`already_done`,r.alreadyDone],t[89]=r.alreadyDone,t[90]=N);let P;t[91]===r.irrelevant?P=t[92]:(P=[`irrelevant`,r.irrelevant],t[91]=r.irrelevant,t[92]=P);let F;t[93]===r.later?F=t[94]:(F=[`too_early`,r.later],t[93]=r.later,t[94]=F);let I;t[95]===r.sourceIncorrect?I=t[96]:(I=[`source_incorrect`,r.sourceIncorrect],t[95]=r.sourceIncorrect,t[96]=I);let L;t[97]===r.lessLikeThis?L=t[98]:(L=[`less_like_this`,r.lessLikeThis],t[97]=r.lessLikeThis,t[98]=L);let ee;t[99]!==N||t[100]!==P||t[101]!==F||t[102]!==I||t[103]!==L?(ee=[N,P,F,I,L],t[99]=N,t[100]=P,t[101]=F,t[102]=I,t[103]=L,t[104]=ee):ee=t[104];let te=ee,z;t[105]!==c||t[106]!==v||t[107]!==te?(z=(0,$.jsx)(`div`,{className:`absolute right-0 z-20 mt-1 w-44 rounded-xl border border-edge bg-surface-overlay p-1 shadow-float`,children:te.map(e=>{let[t,n]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-10 w-full rounded-lg px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>c(v,t),children:n},t)})}),t[105]=c,t[106]=v,t[107]=te,t[108]=z):z=t[108];let B;t[109]!==M||t[110]!==z?(B=(0,$.jsxs)(`details`,{className:`relative ml-auto`,children:[M,z]}),t[109]=M,t[110]=z,t[111]=B):B=t[111];let V;t[112]!==O||t[113]!==A||t[114]!==B||t[115]!==E?(V=(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2`,children:[E,O,A,B]}),t[112]=O,t[113]=A,t[114]=B,t[115]=E,t[116]=V):V=t[116];let H;t[117]!==V||t[118]!==C||t[119]!==w||t[120]!==T?(H=(0,$.jsxs)(`div`,{className:`px-5 py-5 sm:px-6`,children:[C,w,T,V]}),t[117]=V,t[118]=C,t[119]=w,t[120]=T,t[121]=H):H=t[121];let U;t[122]!==r.alternatives||t[123]!==g||t[124]!==v.id?(U=g.length>1?(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:r.alternatives}),(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:g.filter(e=>e.id!==v.id).map(e=>(0,$.jsx)(`button`,{type:`button`,className:`min-h-10 rounded-lg border border-edge px-3 text-left text-sm text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>m(e.id),children:e.title},e.id))})]}):null,t[122]=r.alternatives,t[123]=g,t[124]=v.id,t[125]=U):U=t[125];let W;return t[126]!==r.aiLabel||t[127]!==H||t[128]!==U?(W=(0,$.jsxs)(`section`,{className:`mt-7 rounded-2xl border border-accent/25 bg-surface-base`,"aria-label":r.aiLabel,children:[H,U]}),t[126]=r.aiLabel,t[127]=H,t[128]=U,t[129]=W):W=t[129],W}function De(e){return(0,$.jsx)(`li`,{children:e.message},`${e.kind}:${e.capability}`)}var Oe=new Set([`started`,`discussing`,`completed`]);function ke(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[0,1,2].map(Ae)}),e[0]=t):t=e[0],t}function Ae(e){return(0,$.jsxs)(`div`,{className:`space-y-2 rounded-xl border border-edge-subtle p-4`,children:[(0,$.jsx)(k,{className:`h-4 w-24 rounded`}),(0,$.jsx)(k,{className:`h-5 w-4/5 rounded`}),(0,$.jsx)(k,{className:`h-4 w-3/5 rounded`})]},e)}function je(e){let t=(0,Z.c)(11),{open:n,refreshKey:r,onOpenChange:i,onReevaluate:o}=e,s=m(Ne),u=f(s).projectsPage.home,p=a(),[S,C]=(0,Q.useState)(`all`),w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=[],t[0]=w):w=t[0];let[T,E]=(0,Q.useState)(w),[O,k]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(),N;t[1]===n?N=t[2]:(N=()=>{if(!n)return;let e=!0;return k(!0),M(void 0),F().then(t=>{e&&E(t.items)}).catch(t=>{e&&M(t instanceof Error?t.message:String(t))}).finally(()=>{e&&k(!1)}),()=>{e=!1}},t[1]=n,t[2]=N);let P;t[3]!==n||t[4]!==r?(P=[n,r],t[3]=n,t[4]=r,t[5]=P):P=t[5],(0,Q.useEffect)(N,P);let I=T.filter(e=>S===`all`||(S===`adopted`?Oe.has(e.status):!Oe.has(e.status))),L=new Intl.DateTimeFormat(s===`zh`?`zh-CN`:`en`,{dateStyle:`medium`}),ee=new Intl.DateTimeFormat(s===`zh`?`zh-CN`:`en`,{dateStyle:`medium`,timeStyle:`short`}),R=new Map;for(let e of I){let t=L.format(new Date(e.updatedAt));R.set(t,[...R.get(t)??[],e])}let te=[...R.entries()],z=e=>e.feedbackKind===`already_done`?u.advisorHistoryStatusCompleted:e.feedbackKind===`irrelevant`?u.advisorHistoryStatusIrrelevant:e.feedbackKind===`source_incorrect`?u.advisorHistoryStatusSourceIncorrect:e.feedbackKind===`less_like_this`?u.advisorHistoryStatusLessLikeThis:{available:u.advisorHistoryStatusAvailable,started:u.advisorHistoryStatusStarted,discussing:u.advisorHistoryStatusDiscussing,completed:u.advisorHistoryStatusCompleted,snoozed:u.advisorHistoryStatusSnoozed,dismissed:u.advisorHistoryStatusDismissed,expired:u.advisorHistoryStatusExpired,superseded:u.advisorHistoryStatusSuperseded}[e.status],B=e=>{if(e.href){i(!1),p(l(`/`,e.href));return}e.status===`discussing`&&(i(!1),p(`/chat/new?${new URLSearchParams({draft:e.opportunity.actionPrompt}).toString()}`))},V;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,$.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim`}),t[6]=V):V=t[6];let ne;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(K,{className:`mt-0.5 size-5 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=ne):ne=t[7];let H;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[8]=H):H=t[8];let U=O?(0,$.jsx)(ke,{}):j?(0,$.jsxs)(`div`,{className:`rounded-xl border border-danger/25 bg-danger-soft p-4 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:u.advisorHistoryLoadFailed}),(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`mt-2`,onClick:()=>i(!1),children:u.advisorHistoryClose})]}):te.length===0?(0,$.jsxs)(`div`,{className:`py-16 text-center`,children:[(0,$.jsx)(K,{className:`mx-auto size-6 text-fg-subtle`,"aria-hidden":!0}),(0,$.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:u.advisorHistoryEmpty}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.advisorHistoryEmptyHint})]}):(0,$.jsx)(`div`,{className:`space-y-6`,children:te.map(e=>{let[t,n]=e;return(0,$.jsxs)(`section`,{"aria-label":t,children:[(0,$.jsx)(`h3`,{className:`mb-2 text-xs font-medium text-fg-subtle`,children:t}),(0,$.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>{let t=!!e.href||e.status===`discussing`,n=[`snoozed`,`dismissed`,`expired`,`superseded`].includes(e.status);return(0,$.jsxs)(`article`,{className:`rounded-xl border border-edge-subtle bg-surface-base p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:z(e)}),(0,$.jsx)(`h4`,{className:`mt-1.5 text-sm font-semibold leading-5 text-fg`,children:e.opportunity.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.opportunity.outcome})]}),(0,$.jsx)(`time`,{className:`shrink-0 text-[11px] text-fg-subtle`,dateTime:new Date(e.updatedAt).toISOString(),children:ee.format(new Date(e.updatedAt))})]}),e.snoozedUntil?(0,$.jsxs)(`p`,{className:`mt-2 inline-flex items-center gap-1 text-xs text-fg-muted`,children:[(0,$.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),u.advisorHistoryReturnsAt,` `,ee.format(new Date(e.snoozedUntil))]}):null,(0,$.jsxs)(`details`,{className:`group mt-3`,children:[(0,$.jsxs)(`summary`,{className:`flex min-h-8 cursor-pointer list-none items-center gap-1 text-xs font-medium text-fg-muted hover:text-fg`,children:[u.advisorHistoryEvidence,(0,$.jsx)(pe,{className:`size-3.5 transition-transform duration-200 group-open:rotate-180 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-2 space-y-1.5 border-l border-edge pl-3 text-xs leading-5 text-fg-muted`,children:e.opportunity.evidence.map(Me)})]}),t||n?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[t?(0,$.jsxs)(D,{type:`button`,variant:`secondary`,className:`min-h-9 text-xs`,onClick:()=>B(e),children:[(0,$.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),e.status===`discussing`?u.advisorHistoryContinueDiscussion:u.advisorHistoryViewProgress]}):null,n?(0,$.jsxs)(D,{type:`button`,variant:`ghost`,className:`min-h-9 text-xs`,onClick:()=>{i(!1),o()},children:[(0,$.jsx)(G,{className:`size-3.5`,"aria-hidden":!0}),u.advisorHistoryReevaluate]}):null]}):null]},e.opportunity.id)})})]},t)})}),W;return t[9]===U?W=t[10]:(W=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:U}),t[9]=U,t[10]=W),(0,$.jsx)(x,{open:n,onOpenChange:i,children:(0,$.jsxs)(v,{children:[V,(0,$.jsxs)(y,{className:`xopc-drawer-right fixed right-0 top-0 z-[90] flex size-full max-w-lg flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none`,"aria-describedby":`home-advisor-history-description`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 border-b border-edge px-5 py-4`,children:[ne,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(b,{className:`text-base font-semibold text-fg`,children:u.advisorHistoryTitle}),(0,$.jsx)(g,{id:`home-advisor-history-description`,className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.advisorHistoryDescription})]}),(0,$.jsx)(_,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`-mr-2 size-9 shrink-0 p-0`,"aria-label":u.advisorHistoryClose,children:H})})]}),(0,$.jsx)(`div`,{className:`shrink-0 border-b border-edge-subtle px-5 py-3`,children:(0,$.jsx)(`div`,{className:`inline-flex rounded-lg bg-surface-inset p-1`,role:`group`,"aria-label":u.advisorHistoryFilterLabel,children:[[`all`,u.advisorHistoryFilterAll],[`adopted`,u.advisorHistoryFilterAdopted],[`other`,u.advisorHistoryFilterOther]].map(e=>{let[t,n]=e;return(0,$.jsx)(`button`,{type:`button`,className:`min-h-9 rounded-md px-3 text-xs font-medium transition-colors duration-150 ${S===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`}`,"aria-pressed":S===t,onClick:()=>C(t),children:n},t)})})}),W]})]})})}function Me(e){return(0,$.jsx)(`li`,{children:e.observation},e.id)}function Ne(e){return e.language}function Pe(e,t){return e.replace(`{{count}}`,String(t))}function Fe(e,t){if(e.state===`disabled`)return null;if(e.state===`ready`){let n=1+e.alternatives.length;return{label:Pe(t.ready,n),detail:e.primary.title,tone:`accent`,refreshing:!!e.stale}}return e.state===`clarification`?{label:t.clarification,detail:e.question.question,tone:`accent`,refreshing:!1}:e.state===`refreshing`?{label:t.refreshing,detail:e.previous?.title??t.refreshingDetail,tone:`accent`,refreshing:!0}:e.reason===`generation_failed`?{label:t.generationFailed,detail:t.generationFailedDetail,tone:`danger`,refreshing:!1}:e.reason===`budget_exhausted`?{label:t.budgetExhausted,detail:t.budgetExhaustedDetail,tone:`warning`,refreshing:!1}:e.reason===`model_unavailable`?{label:t.modelUnavailable,detail:t.modelUnavailableDetail,tone:`warning`,refreshing:!1}:{label:t.idle,detail:t.idleDetail,tone:`neutral`,refreshing:!1}}var Ie={accent:`bg-accent`,danger:`bg-danger`,neutral:`bg-fg-subtle`,warning:`bg-warning`};function Le(e){let t=(0,Z.c)(50),{advisor:n,busy:r,copy:i,onOpenHistory:a,onRefresh:o}=e,[s,c]=(0,Q.useState)(!1),l;t[0]!==n||t[1]!==i?(l=Fe(n,i),t[0]=n,t[1]=i,t[2]=l):l=t[2];let u=l;if(!u)return null;let d=n.state!==`refreshing`,f=n.state===`ready`?i.findAnother:i.retry,m=`${i.label}:${u.label}`,h;t[3]===u.refreshing?h=t[4]:(h=u.refreshing?(0,$.jsx)(G,{className:`size-3.5 shrink-0 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(R,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[3]=u.refreshing,t[4]=h);let g=Ie[u.tone],_;t[5]===g?_=t[6]:(_=p(`size-1.5 shrink-0 rounded-full`,g),t[5]=g,t[6]=_);let v;t[7]===_?v=t[8]:(v=(0,$.jsx)(`span`,{className:_,"aria-hidden":!0}),t[7]=_,t[8]=v);let y;t[9]!==i.label||t[10]!==u.label?(y=(0,$.jsxs)(`span`,{className:`truncate`,children:[i.label,` · `,u.label]}),t[9]=i.label,t[10]=u.label,t[11]=y):y=t[11];let b;t[12]!==m||t[13]!==h||t[14]!==v||t[15]!==y?(b=(0,$.jsx)(L,{asChild:!0,children:(0,$.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-9 max-w-56 rounded-lg px-2.5`,"aria-label":m,children:[h,v,y]})}),t[12]=m,t[13]=h,t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]===u.refreshing?x=t[18]:(x=(0,$.jsx)(`span`,{className:`mt-1 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent`,children:u.refreshing?(0,$.jsx)(G,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,$.jsx)(R,{className:`size-4`,"aria-hidden":!0})}),t[17]=u.refreshing,t[18]=x);let S;t[19]===u.label?S=t[20]:(S=(0,$.jsx)(`p`,{className:`font-semibold text-fg`,children:u.label}),t[19]=u.label,t[20]=S);let C;t[21]===u.detail?C=t[22]:(C=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u.detail}),t[21]=u.detail,t[22]=C);let w;t[23]!==S||t[24]!==C?(w=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[23]=S,t[24]=C,t[25]=w):w=t[25];let E;t[26]!==w||t[27]!==x?(E=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[x,w]}),t[26]=w,t[27]=x,t[28]=E):E=t[28];let O;t[29]===a?O=t[30]:(O=()=>{c(!1),a()},t[29]=a,t[30]=O);let k;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),t[31]=k):k=t[31];let A;t[32]!==i.history||t[33]!==O?(A=(0,$.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:O,children:[k,i.history]}),t[32]=i.history,t[33]=O,t[34]=A):A=t[34];let j;t[35]!==r||t[36]!==d||t[37]!==o||t[38]!==f?(j=d?(0,$.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg text-xs`,disabled:r,onClick:()=>{c(!1),o()},children:[(0,$.jsx)(G,{className:`size-3.5`,"aria-hidden":!0}),f]}):null,t[35]=r,t[36]=d,t[37]=o,t[38]=f,t[39]=j):j=t[39];let M;t[40]!==A||t[41]!==j?(M=(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-end gap-1 border-t border-edge-subtle pt-3`,children:[A,j]}),t[40]=A,t[41]=j,t[42]=M):M=t[42];let N;t[43]!==E||t[44]!==M?(N=(0,$.jsx)(T,{children:(0,$.jsxs)(I,{side:`bottom`,align:`end`,sideOffset:6,className:`z-[70] w-[min(21rem,calc(100vw-1.5rem))] rounded-xl border border-edge bg-surface-panel p-4 text-sm text-fg shadow-popover outline-none`,onOpenAutoFocus:Re,children:[E,M]})}),t[43]=E,t[44]=M,t[45]=N):N=t[45];let P;return t[46]!==s||t[47]!==N||t[48]!==b?(P=(0,$.jsxs)(J,{open:s,onOpenChange:c,children:[b,N]}),t[46]=s,t[47]=N,t[48]=b,t[49]=P):P=t[49],P}function Re(e){return e.preventDefault()}function ze({taskId:e,language:t,onComplete:n}){let r=t===`zh`,[i,a]=(0,Q.useState)(),[o,s]=(0,Q.useState)(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{let t=!0;return s(void 0),a(void 0),C(e).then(e=>{t&&a(e)}).catch(e=>{t&&s(e instanceof Error?e.message:String(e))}),()=>{t=!1}},[e,u]);let f=i?Y(i):[],p=i?.task.phase===`review`&&i.allowedCommands.includes(`close`)&&i.waits.length===0&&f.length>0&&f.every(e=>e.status===`passed`);async function m(e,t=!1){if(!c){l(!0),s(void 0);try{a(await e()),t&&n()}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}}let h=i?.receipts[0];return(0,$.jsxs)(`section`,{className:`mt-4 space-y-4 rounded-xl border border-edge bg-surface-panel p-4`,"aria-label":r?`任务验收`:`Task review`,children:[o?(0,$.jsxs)(`div`,{role:`alert`,className:`flex items-center justify-between gap-3 text-sm text-danger`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(D,{variant:`ghost`,disabled:c,onClick:()=>d(e=>e+1),children:r?`刷新`:`Refresh`})]}):null,!i&&!o?(0,$.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,$.jsx)(k,{className:`h-5 w-1/3`}),(0,$.jsx)(k,{className:`h-24 w-full`})]}):null,i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r?`执行结果`:`Result`}),h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{content:h.summary,contentKey:`home:${e}:result`,language:t,previewHeight:180}),h.remainingWork.length>0?(0,$.jsxs)(`p`,{className:`whitespace-pre-wrap text-sm text-fg-muted`,children:[r?`尚待完成:`:`Remaining work: `,h.remainingWork.join(`
|
|
2
|
-
`)]}):null,h.evidence.map((e,t)=>(0,$.jsxs)(`div`,{className:`text-sm text-fg-muted`,children:[e.uri&&/^https?:\/\//.test(e.uri)?(0,$.jsx)(`a`,{href:e.uri,target:`_blank`,rel:`noreferrer`,className:`text-accent-fg hover:underline`,children:e.title}):(0,$.jsx)(`span`,{children:e.title}),e.summary?(0,$.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words`,children:e.summary}):null]},t))]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r?`暂无执行结果,请查看任务详情。`:`No result yet. View the task details.`}),(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r?`验收条件`:`Acceptance criteria`}),f.map((t,n)=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2 border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 text-sm text-fg`,children:[(0,$.jsx)(`p`,{className:`break-words`,children:t.text}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r?{passed:`已通过`,failed:`未通过`,unverified:`待判定`}[t.status]:{passed:`Passed`,failed:`Failed`,unverified:`Not reviewed`}[t.status]})]}),i.task.phase!==`closed`&&i.task.contract?.acceptancePolicy!==`verified_auto`?(0,$.jsx)(`div`,{className:`flex gap-2`,children:[`passed`,`failed`].map(a=>(0,$.jsx)(D,{variant:`secondary`,disabled:c||t.status===a,onClick:()=>void m(()=>oe(e,n,a,i.task.version,i.task.latestContractVersion)),children:r?a===`passed`?`确认通过`:`未通过`:a===`passed`?`Mark passed`:`Mark failed`},a))}):null]},n)),p?null:(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r?`所有验收条件通过且任务无等待事项后,可完成验收。`:`Accept once all criteria pass and the task has no pending waits.`}),(0,$.jsx)(D,{variant:`primary`,disabled:c||!p,onClick:()=>void m(()=>q(e,{type:`close`,resolution:`done`},i.task.version),!0),children:r?`验收完成`:`Accept task`})]}):null]})}async function Be(e,t=`en`){let n=await C(e),r=n.runs.filter(e=>!e.parentRunId).sort((e,t)=>t.queuedAt-e.queuedAt)[0];if(!n.allowedCommands.includes(`start`)||r?.status!==`failed`)throw Error(t===`zh`?`任务状态已变化,暂时无法重试。请刷新并查看当前状态。`:`Task is no longer available for retry. Refresh and review its current state.`);await q(e,{type:`start`,executor:S.parse({...r.executorRef,kind:r.executorKind})},n.task.version)}function Ve(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function He(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`div`,{className:`space-y-8`,"aria-busy":!0,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(k,{className:`h-10 w-3/5 rounded-xl`}),(0,$.jsx)(k,{className:`h-5 w-4/5 rounded-lg`})]}),(0,$.jsx)(k,{className:`h-64 rounded-2xl`}),(0,$.jsx)(k,{className:`h-32 rounded-xl`})]}),e[0]=t):t=e[0],t}function Ue(e){let t=(0,Z.c)(50),{item:n,busy:r,recommendationLabel:i,dueLabel:a,failureLabel:s,locale:c,onAction:l,onComplete:u}=e,[d,f]=o(),p=n.primaryAction?.type===`task_review`?n.primaryAction:void 0,m;t[0]!==p||t[1]!==d?(m=p&&d.get(`reviewTask`)===p.taskId,t[0]=p,t[1]=d,t[2]=m):m=t[2];let h=!!m,g;t[3]!==p||t[4]!==d||t[5]!==f?(g=e=>{let t=new URLSearchParams(d);e&&p?t.set(`reviewTask`,p.taskId):t.delete(`reviewTask`),f(t)},t[3]=p,t[4]=d,t[5]=f,t[6]=g):g=t[6];let _=g,v;t[7]!==a||t[8]!==n.dueAt||t[9]!==c?(v=n.dueAt?`${a} ${M(new Date(n.dueAt),c)}`:null,t[7]=a,t[8]=n.dueAt,t[9]=c,t[10]=v):v=t[10];let y=v,b=n.kind===`failure`?s:y,x;t[11]===b?x=t[12]:(x=b?(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-medium text-warning`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`,"aria-hidden":!0}),(0,$.jsx)(`span`,{children:b})]}):null,t[11]=b,t[12]=x);let S=!n.openAction,C;t[13]!==n.id||t[14]!==n.openAction||t[15]!==l?(C=()=>n.openAction&&l(n.openAction,n.id),t[13]=n.id,t[14]=n.openAction,t[15]=l,t[16]=C):C=t[16];let w;t[17]===n.title?w=t[18]:(w=(0,$.jsx)(`span`,{className:`block text-lg font-semibold leading-7 tracking-tight text-fg`,children:n.title}),t[17]=n.title,t[18]=w);let T;t[19]===n.summary?T=t[20]:(T=(0,$.jsx)(`span`,{className:`mt-1.5 block text-sm leading-6 text-fg-muted`,children:n.summary}),t[19]=n.summary,t[20]=T);let E;t[21]!==S||t[22]!==C||t[23]!==w||t[24]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,className:`block w-full text-left outline-none focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:S,onClick:C,children:[w,T]}),t[21]=S,t[22]=C,t[23]=w,t[24]=T,t[25]=E):E=t[25];let O;t[26]!==n.recommendation||t[27]!==i?(O=n.recommendation?(0,$.jsxs)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`font-semibold text-fg`,children:[i,`:`]}),n.recommendation]}):null,t[26]=n.recommendation,t[27]=i,t[28]=O):O=t[28];let k;t[29]!==r||t[30]!==n.id||t[31]!==n.primaryAction||t[32]!==n.secondaryActions||t[33]!==l||t[34]!==p||t[35]!==h||t[36]!==_?(k=n.primaryAction||n.secondaryActions.length>0?(0,$.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[n.primaryAction?(0,$.jsx)(D,{type:`button`,variant:`primary`,className:`h-9 rounded-lg px-3.5 text-xs`,disabled:r,"aria-expanded":p?h:void 0,onClick:()=>p?_(!h):l(n.primaryAction,n.id),children:n.primaryAction.label}):null,n.secondaryActions.map(e=>(0,$.jsx)(D,{type:`button`,variant:`secondary`,className:`h-9 rounded-lg px-3.5 text-xs shadow-none`,disabled:r,onClick:()=>l(e,n.id),children:e.label},`${e.type}:${e.label}`))]}):null,t[29]=r,t[30]=n.id,t[31]=n.primaryAction,t[32]=n.secondaryActions,t[33]=l,t[34]=p,t[35]=h,t[36]=_,t[37]=k):k=t[37];let A;t[38]!==c||t[39]!==u||t[40]!==p||t[41]!==h||t[42]!==_?(A=h&&p?(0,$.jsx)(ze,{taskId:p.taskId,language:c,onComplete:()=>{_(!1),u()}}):null,t[38]=c,t[39]=u,t[40]=p,t[41]=h,t[42]=_,t[43]=A):A=t[43];let j;return t[44]!==O||t[45]!==k||t[46]!==A||t[47]!==x||t[48]!==E?(j=(0,$.jsxs)(`article`,{className:`px-5 py-5 sm:px-6 sm:py-6`,children:[x,E,O,k,A]}),t[44]=O,t[45]=k,t[46]=A,t[47]=x,t[48]=E,t[49]=j):j=t[49],j}function We(e){let t=(0,Z.c)(26),{item:n,onAction:r}=e,i;t[0]===n.kind?i=t[1]:(i=n.kind===`scheduled`?(0,$.jsx)(le,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(`span`,{className:`size-1.5 rounded-full bg-success`,"aria-hidden":!0}),t[0]=n.kind,t[1]=i);let a=i,o=!n.openAction,s;t[2]!==n.id||t[3]!==n.openAction||t[4]!==r?(s=()=>n.openAction&&r(n.openAction,n.id),t[2]=n.id,t[3]=n.openAction,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center text-fg-subtle`,children:a}),t[6]=a,t[7]=c);let l;t[8]===n.title?l=t[9]:(l=(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.title}),t[8]=n.title,t[9]=l);let u;t[10]===n.summary?u=t[11]:(u=(0,$.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.summary}),t[10]=n.summary,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===n.statusLabel?f=t[16]:(f=n.statusLabel?(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.statusLabel}):null,t[15]=n.statusLabel,t[16]=f);let p;t[17]===n.openAction?p=t[18]:(p=n.openAction?(0,$.jsx)(U,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[17]=n.openAction,t[18]=p);let m;return t[19]!==o||t[20]!==s||t[21]!==c||t[22]!==d||t[23]!==f||t[24]!==p?(m=(0,$.jsxs)(`button`,{type:`button`,className:`flex min-h-16 w-full items-center gap-3 py-3 text-left outline-none hover:text-fg focus-visible:rounded-md focus-visible:ring-2 focus-visible:ring-accent`,disabled:o,onClick:s,children:[c,d,f,p]}),t[19]=o,t[20]=s,t[21]=c,t[22]=d,t[23]=f,t[24]=p,t[25]=m):m=t[25],m}function Ge(){let e=m(e=>e.language),t=f(e),n=t.projectsPage,r=ie(e),o=a(),s=i(),c=te(e=>e.setPageHeader),p=te(e=>e.clearPageHeader),{home:S,loading:C,loadError:T,setLoadError:k,load:A}=ve(e,s.key),[j,M]=(0,Q.useState)(!1),[N,F]=(0,Q.useState)(``),I=(0,Q.useRef)(!1),[L,ee]=(0,Q.useState)(null),[R,V]=(0,Q.useState)(!1),[ne,U]=(0,Q.useState)(),[G,re]=(0,Q.useState)(!1),[oe,le]=(0,Q.useState)(0),[K,q]=(0,Q.useState)(),[pe,J]=(0,Q.useState)(),[ge,_e]=(0,Q.useState)(!1),Y=O({chat:t.chat}),X=(0,Q.useRef)(null),Z=z({disabled:ge,chat:t.chat,onTranscript:e=>{F(t=>P(t,e)),window.setTimeout(()=>X.current?.focus(),0)}}),{phase:ye,voiceActive:xe,startVoiceInput:Se,cancelVoiceInput:Ce,confirmVoiceInput:we,retryVoiceInput:Te}=Z;(0,Q.useEffect)(()=>{if(!K)return;let e=window.setTimeout(()=>q(void 0),8e3);return()=>window.clearTimeout(e)},[K]);let De=(0,Q.useCallback)(async e=>{if(!(e.length===0||ge)){_e(!0);try{await Y.processFiles(e)}finally{_e(!1)}}},[ge,Y.processFiles]),Oe=(0,Q.useCallback)(async e=>{let t=H(e.clipboardData);t.length!==0&&(e.preventDefault(),await De(t))},[De]),ke=(0,Q.useCallback)(e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,Y.setIsDragging(!0))},[Y.setIsDragging]),Ae=(0,Q.useCallback)(e=>{let t=e.relatedTarget;(!(t instanceof Node)||!e.currentTarget.contains(t))&&Y.setIsDragging(!1)},[Y.setIsDragging]),Me=(0,Q.useCallback)(async e=>{e.preventDefault(),Y.setIsDragging(!1),await De(Array.from(e.dataTransfer.files))},[Y.setIsDragging,De]),Ne=(0,Q.useCallback)(e=>{e.preventDefault();let t=Y.wireAttachmentsPayload(),n=se(N,t.length>0?de(t):void 0,{projectScope:`none`});n&&(M(!1),F(``),Y.clearAttachments(),o(n))},[Y.clearAttachments,Y.wireAttachmentsPayload,N,o]),Pe=Y.attachments.length>=10,Fe={attachTitle:Pe?Ve(t.chat.maxAttachmentsReached,{max:10}):`${t.chat.attachFile} (${Y.attachments.length}/10)`,dropFiles:t.chat.dropFiles,intentLabel:r.intentLabel,intentPlaceholder:r.intentPlaceholder,intentSuggestion:r.intentSuggestion,shortcut:n.home.submitShortcut,submit:r.newWork},Ie=(0,Q.useMemo)(()=>({label:n.home.advisorStatusLabel,ready:n.home.advisorStatusReady,clarification:n.home.advisorStatusClarification,refreshing:n.home.advisorStatusRefreshing,refreshingDetail:n.home.advisorRefreshing,idle:n.home.advisorStatusIdle,idleDetail:n.home.advisorUnavailableTitle,generationFailed:n.home.advisorStatusGenerationFailed,budgetExhausted:n.home.advisorStatusBudgetExhausted,modelUnavailable:n.home.advisorStatusModelUnavailable,generationFailedDetail:n.home.advisorGenerationFailed,budgetExhaustedDetail:n.home.advisorBudgetExhausted,modelUnavailableDetail:n.home.advisorModelUnavailable,history:n.home.advisorHistory,retry:n.home.retry,findAnother:n.home.advisorRefresh}),[n.home]),Re=!!(S&&S.needsUser.length===0&&S.backgroundCount===0),ze=!!(S&&S.needsUser.length===0),Ge=ze||j;(0,Q.useEffect)(()=>{!Ge&&xe&&Ce()},[Ce,Ge,xe]),(0,Q.useEffect)(()=>{let e=e=>{let t=e.detail?.target;t&&t!==`chat`||!Ge||ge||(e.preventDefault(),ye===`recording`?we():ye===`idle`?(X.current?.focus(),Se()):ye===`error`&&Te())},t=e=>{let t=e.detail?.target;t&&t!==`chat`||!Ge||!xe||(e.preventDefault(),Ce(),X.current?.focus())};return window.addEventListener(ce,e),window.addEventListener(w,t),()=>{window.removeEventListener(ce,e),window.removeEventListener(w,t)}},[ge,Ce,Ge,we,Te,Se,xe,ye]);let Ke=(0,Q.useCallback)(e=>{e||Ce(),M(e)},[Ce]),qe=(0,Q.useCallback)((t,n)=>{if(t.type===`open`){o(l(`/`,t.href));return}t.type===`task_review`||I.current||(I.current=!0,ee(n),k(null),(async()=>{try{t.type===`retry_task`?await Be(t.taskId,e):t.type===`connector_decision`?await ue({kind:`connector_approval`,approvalId:t.approvalId},t.decision):t.type===`retry_run`?await fe({kind:t.subjectKind,runId:t.runId}):t.type===`acknowledge_run`&&await B({kind:t.subjectKind,runId:t.runId}),await A()}catch(e){k(e instanceof Error?e.message:String(e))}finally{I.current=!1,ee(null)}})())},[e,A,o]),Je=(0,Q.useCallback)(()=>{V(!0),U(void 0),J(void 0),k(null),he(e).then(()=>A()).catch(e=>k(e instanceof Error?e.message:String(e))).finally(()=>V(!1))},[e,A]),Ye=(0,Q.useCallback)((e,t)=>{V(!0),k(null),E(e,t).then(async t=>{if(t.outcome===`needs_setup`){J({opportunityId:e.id,value:t.preflight});return}if(J(void 0),le(e=>e+1),t.outcome===`task`){U({title:n.home.advisorStartedTitle,detail:Ve(n.home.advisorStartedDetail,{title:e.title}),href:l(`/`,t.href)}),await A();return}o(t.href)}).catch(e=>k(e instanceof Error?e.message:String(e))).finally(()=>V(!1))},[A,o,n.home.advisorStartedDetail,n.home.advisorStartedTitle]),Xe=(0,Q.useCallback)((e,t)=>{V(!0),U(void 0),J(void 0),k(null),W(e,{kind:t,snoozedUntil:t===`too_early`?Date.now()+4320*6e4:void 0}).then(({idempotencyKey:t})=>(q({opportunityId:e.id,idempotencyKey:t}),le(e=>e+1),A())).catch(e=>k(e instanceof Error?e.message:String(e))).finally(()=>V(!1))},[A]),Ze=(0,Q.useCallback)(()=>{if(!K)return;let e=K;q(void 0),V(!0),k(null),me(e.opportunityId,e.idempotencyKey).then(()=>(le(e=>e+1),A())).catch(t=>{q(e),k(t instanceof Error?t.message:String(t))}).finally(()=>V(!1))},[K,A]),Qe=(0,Q.useCallback)((e,t)=>{o(`/chat/new?${new URLSearchParams({draft:`${e}\n\n${t}`}).toString()}`)},[o]),$e=(0,Q.useMemo)(()=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[S?(0,$.jsx)(Le,{advisor:S.advisor,busy:R,copy:Ie,onOpenHistory:()=>re(!0),onRefresh:Je}):null,ze?null:(0,$.jsxs)(D,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>M(!0),children:[(0,$.jsx)(u,{className:`size-4`,"aria-hidden":!0}),r.newWork]})]}),[R,Ie,r.newWork,S,Je,ze]);(0,Q.useLayoutEffect)(()=>(c({startExtra:null,main:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),end:$e}),()=>p()),[p,$e,c,n.title]);let et=S?.needsUser.length??0,tt=S?.backgroundCount??0,nt=et>0?Ve(n.home.attentionTitle,{count:et}):tt>0?n.home.clearTitle:n.home.idleTitle,rt=et>0?tt>0?Ve(n.home.attentionIntroWithBackground,{count:tt}):n.home.attentionIntro:tt>0?Ve(n.home.clearIntro,{count:tt}):n.home.idleIntro;return(0,$.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[920px] flex-1 flex-col px-4 pb-8 pt-3 sm:px-6 lg:px-8 lg:pb-12 lg:pt-4`,children:[(0,$.jsx)(`input`,{ref:Y.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=e.target.files;t&&De(Array.from(t)),e.target.value=``}}),(0,$.jsx)(x,{open:j,onOpenChange:Ke,children:(0,$.jsxs)(v,{children:[(0,$.jsx)(h,{className:`xopc-dialog-overlay fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,$.jsxs)(y,{className:`xopc-dialog-content fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-float focus:outline-none`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(b,{className:`text-base font-semibold text-fg`,children:r.dialogTitle}),(0,$.jsx)(g,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:r.dialogDescription})]}),(0,$.jsx)(_,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:n.cancel,"aria-label":n.cancel,children:(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsx)(be,{variant:`dialog`,inputId:`new-conversation-intent`,inputRef:X,intent:N,labels:{...Fe,submit:r.submit},attachments:Y.attachments,isDragging:Y.isDragging,attachmentBusy:ge,attachmentsFull:Pe,voice:Z,chat:t.chat,cancelAction:(0,$.jsx)(_,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`ghost`,children:n.cancel})}),onIntentChange:F,onPickFiles:()=>Y.fileInputRef.current?.click(),onRemoveAttachment:Y.removeAttachment,onPaste:e=>void Oe(e),onDragOver:ke,onDragLeave:Ae,onDrop:e=>void Me(e),onSubmit:Ne})]})]})}),(0,$.jsx)(je,{open:G,refreshKey:oe,onOpenChange:re,onReevaluate:Je}),T?(0,$.jsxs)(`div`,{className:`mb-6 flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,$.jsx)(`span`,{children:T}),(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void A(),children:n.home.retry})]}):null,C?(0,$.jsx)(He,{}):S?(0,$.jsxs)(`div`,{className:Re?`mx-auto my-auto w-full max-w-[640px]`:`w-full`,children:[(0,$.jsxs)(`section`,{className:Re?`w-full text-center`:`max-w-3xl`,children:[(0,$.jsx)(`h2`,{className:`text-3xl font-semibold leading-tight tracking-[-0.035em] text-fg sm:text-4xl`,children:nt}),(0,$.jsx)(`p`,{className:Re?`mx-auto mt-3 max-w-xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`:`mt-3 max-w-2xl text-sm leading-6 text-fg-muted sm:text-base sm:leading-7`,children:rt})]}),ze?(0,$.jsx)(be,{variant:`inline`,inputId:`home-conversation-intent`,inputRef:X,intent:N,labels:Fe,attachments:Y.attachments,isDragging:Y.isDragging,attachmentBusy:ge,attachmentsFull:Pe,voice:Z,chat:t.chat,onIntentChange:F,onPickFiles:()=>Y.fileInputRef.current?.click(),onRemoveAttachment:Y.removeAttachment,onPaste:e=>void Oe(e),onDragOver:ke,onDragLeave:Ae,onDrop:e=>void Me(e),onSubmit:Ne}):null,(0,$.jsx)(Ee,{advisor:S.advisor,busy:R,copy:{aiLabel:n.home.advisorAiLabel,why:n.home.advisorWhy,evidence:n.home.advisorEvidence,needsSetup:n.home.advisorNeedsSetup,start:n.home.advisorStart,discuss:n.home.advisorDiscuss,refresh:n.home.advisorRefresh,refreshing:n.home.advisorRefreshing,history:n.home.advisorHistory,viewProgress:n.home.advisorViewProgress,alternatives:n.home.advisorAlternatives,feedback:n.home.advisorFeedback,alreadyDone:n.home.advisorAlreadyDone,irrelevant:n.home.advisorIrrelevant,later:n.home.advisorLater,lessLikeThis:n.home.advisorLessLikeThis,sourceIncorrect:n.home.advisorSourceIncorrect,minutes:n.home.advisorMinutes,setupTitle:n.home.advisorSetupTitle,setupHint:n.home.advisorSetupHint,configure:n.home.advisorConfigure,degradedStart:n.home.advisorDegradedStart,automationHint:n.home.advisorAutomationHint,automationAction:n.home.advisorAutomationAction},onRefresh:Je,onAction:Ye,onFeedback:Xe,onClarification:Qe,onOpenHistory:()=>re(!0),preflight:pe,receipt:ne}),S.needsUser.length>0?(0,$.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-needs-user-title`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 px-1`,children:[(0,$.jsx)(ae,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,$.jsx)(`h2`,{id:`home-needs-user-title`,className:`text-sm font-semibold text-fg`,children:n.home.needsUserTitle})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge-subtle bg-surface-base`,children:S.needsUser.map(t=>(0,$.jsx)(Ue,{item:t,busy:L!==null,recommendationLabel:n.home.recommendationLabel,dueLabel:n.home.dueLabel,failureLabel:r.runAttention,locale:e,onAction:qe,onComplete:()=>void A()},t.id))})]}):null,S.background.length>0?(0,$.jsxs)(`section`,{className:`mt-10`,"aria-labelledby":`home-background-title`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-1`,children:[(0,$.jsx)(`h2`,{id:`home-background-title`,className:`text-sm font-semibold text-fg`,children:n.home.backgroundTitle}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Ve(n.home.backgroundCount,{count:S.backgroundCount})})]}),(0,$.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle border-y border-edge-subtle`,children:S.background.map(e=>(0,$.jsx)(We,{item:e,onAction:qe},e.id))})]}):null]}):null,K?(0,$.jsxs)(`div`,{role:`status`,className:`fixed bottom-5 left-1/2 z-[100] flex -translate-x-1/2 items-center gap-4 rounded-lg border border-edge bg-surface-panel px-4 py-3 text-sm text-fg shadow-float`,children:[(0,$.jsx)(`span`,{children:n.home.advisorFeedbackSaved}),(0,$.jsx)(`button`,{type:`button`,className:`font-medium text-accent-fg hover:underline`,onClick:Ze,children:n.home.advisorUndo})]}):null]})}export{Ge as HomePage};
|