@dominevo/addon-admin-ui 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/assets/{Addons-Ck90J9_n.js → Addons-CpGBhr79.js} +1 -1
- package/dist/assets/{AdminPage-CA4Sxydy.js → AdminPage-B35tMynm.js} +1 -1
- package/dist/assets/{AdminSectionedPage-3XsaKUPh.js → AdminSectionedPage-RkQwEpsd.js} +1 -1
- package/dist/assets/{AiProfiles-8UssQtkR.js → AiProfiles-DXGNZOrG.js} +1 -1
- package/dist/assets/{Archive-5WNTy09R.js → Archive-DzwbviB7.js} +1 -1
- package/dist/assets/{BootstrapSettingsForm-CQLdqB1p.js → BootstrapSettingsForm-rb7h24St.js} +1 -1
- package/dist/assets/{Build-B6m8-obM.js → Build-B_K5vb1t.js} +1 -1
- package/dist/assets/{Calendars-BbmdZy07.js → Calendars-BG_DXgqB.js} +1 -1
- package/dist/assets/{Cluster-CzmgBDwN.js → Cluster-2e-1VXUZ.js} +1 -1
- package/dist/assets/{CompositionBlockEditor-DjJGal7a.js → CompositionBlockEditor-DqEQH8XZ.js} +1 -1
- package/dist/assets/{CompositionEditorPage-MACY9CFt.js → CompositionEditorPage-CgCRQbi2.js} +1 -1
- package/dist/assets/{Data-B2mmPVLY.js → Data-U9aDnpkV.js} +1 -1
- package/dist/assets/{DeviceDetail-D7GFYFEm.js → DeviceDetail-BLqSn8fF.js} +1 -1
- package/dist/assets/{Devices-NJ52UGWV.js → Devices-ZWTiajGA.js} +1 -1
- package/dist/assets/{EmbedDevicePage-F1NEkMUT.js → EmbedDevicePage-WrtMODXs.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BKq1BRg_.js → EmbedPlayerPage-B230r_Ap.js} +1 -1
- package/dist/assets/{FormBuilder-BjcOGVVa.js → FormBuilder-BB51iHrB.js} +1 -1
- package/dist/assets/{History-CqTLHyoj.js → History-B69xY-Vn.js} +1 -1
- package/dist/assets/Identity-DrmPc3tf.js +1 -0
- package/dist/assets/{InstancesTable-CCUTp360.js → InstancesTable-2NB3K6Bc.js} +1 -1
- package/dist/assets/{IntegrationDetail-CCyZhNWc.js → IntegrationDetail-B5OYMOWk.js} +1 -1
- package/dist/assets/{Integrations-B_Inbdpc.js → Integrations-C7ImeOVN.js} +1 -1
- package/dist/assets/{Integrations-D1Ybtztv.js → Integrations-y6KQI_YG.js} +1 -1
- package/dist/assets/{Jobs-BDZ-S8az.js → Jobs-C0DpPNi0.js} +1 -1
- package/dist/assets/{Library-BJXSgpWZ.js → Library-Dn9F2bob.js} +1 -1
- package/dist/assets/{Locations-CEsFxXK8.js → Locations-tcBTN0CL.js} +1 -1
- package/dist/assets/{Logs-DrLmsP4V.js → Logs-Ddwn_Is0.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-T6ZNfW4J.js → MaskShapeCanvas-B5mehyBe.js} +1 -1
- package/dist/assets/{MotionZonesSettings-B5KDfHoK.js → MotionZonesSettings-jMkiUUQz.js} +1 -1
- package/dist/assets/{MyAccess-CAtcn_a3.js → MyAccess-C0OQAAby.js} +1 -1
- package/dist/assets/{Network-BUfXtVhQ.js → Network-Cu87Zl0W.js} +1 -1
- package/dist/assets/{NewExportModal-D64AhGe8.js → NewExportModal-DEpoqntE.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-hnXBekcO.js → NodeAddonsSettingsPanel-Bgq8ERZo.js} +1 -1
- package/dist/assets/{Notifications-CrrX9yK9.js → Notifications-kCFGMKK7.js} +1 -1
- package/dist/assets/{Pipeline-BGOu-2v_.js → Pipeline-B-k1j81-.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CERwQtiu.js → PrivacyMaskSettings-C4XdrpKI.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-DxTYd8U2.js → SceneMonitorEditor-3kjADoN0.js} +1 -1
- package/dist/assets/SessionsList-DJEvmfQv.js +2 -0
- package/dist/assets/{Showroom-CprRp6yl.js → Showroom-DW6kJtdV.js} +1 -1
- package/dist/assets/{StorageLocationsTable-B81bi89X.js → StorageLocationsTable-BpamO2AO.js} +1 -1
- package/dist/assets/{System-D3mpSwHc.js → System-PBIGeygM.js} +1 -1
- package/dist/assets/{TemplateEditorDialog-CwArOYwD.js → TemplateEditorDialog-nX5amI-o.js} +1 -1
- package/dist/assets/{Terminal-Dqxv-P1E.js → Terminal-Bqc_BiMO.js} +1 -1
- package/dist/assets/{TrainingProviders-CGpG1PvO.js → TrainingProviders-BaGY_fsT.js} +1 -1
- package/dist/assets/{Viewer-9ydpkUg6.js → Viewer-K9pbFfye.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Cc7iYWcG.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Iu6fLdXX.js} +1 -1
- package/dist/assets/{ai-page.helpers-CiDsxXp3.js → ai-page.helpers-CH0oD27E.js} +1 -1
- package/dist/assets/{assignment-candidates-BfhoJg-T.js → assignment-candidates-CutnM30g.js} +1 -1
- package/dist/assets/{auth-context-CkfOTCG-.js → auth-context-CbKbPGVG.js} +1 -1
- package/dist/assets/{authed-media-C-zK1a1B.js → authed-media-DDyQ4EVl.js} +1 -1
- package/dist/assets/{board-model-BvqJSvTB.js → board-model-BJOCdYZi.js} +1 -1
- package/dist/assets/{broker-oauth-popup-B_GRcwxo.js → broker-oauth-popup-Bc0452mf.js} +1 -1
- package/dist/assets/{camera-block-model-QrJ_0XZY.js → camera-block-model-Cg9j-LS6.js} +1 -1
- package/dist/assets/{device-integration-icon-B63imyJJ.js → device-integration-icon-DBlkZ4N3.js} +1 -1
- package/dist/assets/device-picker-model-CzwyZiSZ.js +1 -0
- package/dist/assets/{dist-2ETbjdqB.js → dist-DMgC_62x.js} +1 -1
- package/dist/assets/{dist-B0ixn42U.js → dist-DUZyedAc.js} +3 -3
- package/dist/assets/{format-D43HvBR0.js → format-M1wlEHJl.js} +1 -1
- package/dist/assets/{hostInit-BjOFEl3v.js → hostInit-CiMa3W47.js} +1 -1
- package/dist/assets/i18n-kurEJu5K.js +1 -0
- package/dist/assets/{icons-CNI0rnl8.js → icons-nvRYK39P.js} +1 -1
- package/dist/assets/{index-CuIsX0Bx.js → index-uhNZQRiY.js} +3 -3
- package/dist/assets/{linked-devices-model-Dl4vHeXt.js → linked-devices-model-B5XyFLX2.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-395ec2fe.js → mf-entry-bootstrap-0-3b94fe74.js} +2 -2
- package/dist/assets/mount-CzwyZiSZ.js +1 -0
- package/dist/assets/{notification-rule-status-T3SwZb2I.js → notification-rule-status-JiMjbzwM.js} +1 -1
- package/dist/assets/{player-overlays-qzCoRsrQ.js → player-overlays-Cs69NgAR.js} +1 -1
- package/dist/assets/remoteEntry-C4IaCrn1.js +1 -0
- package/dist/assets/{src-CJoX3s-1.js → src-BwDSKCnh.js} +3 -3
- package/dist/assets/{src-Cf1Uvi4o.js → src-DWGf7c88.js} +4 -4
- package/dist/assets/{sso-popup-CPavla3I.js → sso-popup-DVrI_KPY.js} +1 -1
- package/dist/assets/{step-inspector-model-CMrG9Xaa.js → step-inspector-model-BMwzbdW5.js} +1 -1
- package/dist/assets/{use-scenes-feed-CosaOMpn.js → use-scenes-feed-BTeaS3CE.js} +1 -1
- package/dist/assets/{useAdminDeviceRemoval-C5EQsX7f.js → useAdminDeviceRemoval-y6kJG-64.js} +1 -1
- package/dist/assets/{useDevice-JbC1lVOL.js → useDevice-BfL2Lixa.js} +1 -1
- package/dist/assets/useEventInvalidation-CzwyZiSZ.js +1 -0
- package/dist/assets/{useFaultTypeOptions-BCjpEaI1.js → useFaultTypeOptions-DJb6ajuT.js} +1 -1
- package/dist/assets/{useNodeUrlSelection-uTbHSv6T.js → useNodeUrlSelection-Dn1QMWS7.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BZ1YRJXZ.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BZVxl24K.js} +2 -2
- package/dist/index.html +12 -12
- package/dist/server/addon.js +1 -1
- package/package.json +2 -2
- package/dist/assets/Identity-8tZo1PB_.js +0 -1
- package/dist/assets/SessionsList-CriK5VLX.js +0 -2
- package/dist/assets/device-picker-model-CYNi1aEm.js +0 -1
- package/dist/assets/i18n-BHLBFC1-.js +0 -1
- package/dist/assets/mount-CYNi1aEm.js +0 -1
- package/dist/assets/remoteEntry-Dc97BJQ9.js +0 -1
- package/dist/assets/useEventInvalidation-CYNi1aEm.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,S as r,V as i,Y as a,a as o,et as s,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$n as u,Ar as d,D as f,Gi as p,Gt as m,Ri as h,Un as g,X as _,Zn as v,_n as y,_t as b,bt as x,cn as S,er as C,hr as w,ht as T,io as E,ir as D,li as O,mi as ee,oi as k,ri as te,sr as A,va as ne,wr as re,xn as ie,xo as ae,xt as oe,yt as j,zt as M}from"./player-overlays-Cs69NgAR.js";import{Fc as se,Pc as ce,v as N}from"./src-BwDSKCnh.js";import{c as P,d as le,i as F,l as ue,n as de}from"./terminal-BncJ-1sF.js";import{t as fe}from"./file-up-2YD_M6f_.js";import{t as pe}from"./key-CH4aXNMz.js";import{t as me}from"./monitor-smartphone-DPI9EQus.js";import{t as he}from"./unlink-D3-IGpS8.js";import{$ as ge,$a as I,$i as L,$p as _e,Au as ve,Ci as ye,Gp as be,Gr as R,Hp as xe,Im as z,Ir as B,Jp as Se,Jr as Ce,Kp as V,Mc as H,Nr as we,Pa as Te,Qa as Ee,Qp as De,Su as Oe,Ti as ke,Tu as Ae,Up as je,W as Me,Wp as Ne,Xi as Pe,Xp as Fe,Yp as Ie,Yr as Le,Za as U,Zp as Re,_i as ze,aa as W,bu as Be,dm as Ve,ea as He,et as Ue,fm as We,hi as Ge,ia as Ke,k as qe,ku as Je,pm as Ye,qp as Xe,qr as G,ra as Ze,st as K,ta as Qe,um as $e,vi as et,wi as tt}from"./src-DWGf7c88.js";import{i as nt,l as rt,n as it,p as at}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as q}from"./i18n-kurEJu5K.js";import{t as J}from"./useTranslation-uIxPZ_3N.js";import"./FormBuilder-BB51iHrB.js";import{n as ot}from"./auth-context-CbKbPGVG.js";import{$t as st,A as ct,It as lt,_ as ut,a as dt,c as ft,g as Y,h as X,i as pt,l as mt,o as ht,s as gt,t as _t,u as vt}from"./index-uhNZQRiY.js";import{t as yt}from"./AdminSectionedPage-RkQwEpsd.js";import{t as bt}from"./InstancesTable-2NB3K6Bc.js";import{t as xt}from"./AdminPage-B35tMynm.js";import{C as St,D as Ct,E as wt,S as Tt,T as Et,_ as Dt,a as Ot,b as kt,c as At,d as jt,f as Mt,g as Nt,h as Pt,i as Ft,l as It,m as Lt,n as Rt,o as zt,p as Bt,s as Vt,t as Ht,u as Ut,v as Wt,w as Gt,x as Z,y as Kt}from"./SessionsList-DJEvmfQv.js";import{n as qt,t as Jt}from"./BootstrapSettingsForm-rb7h24St.js";s();function Yt(){let{t:e}=J(),t=T(),i=z.useUtils(),o=ut(),{data:s,isLoading:c}=Se(),l=n(()=>s??[],[s]),u=z.useQueries(e=>l.map(t=>e.userManagement.listExternalIdentities({userId:t.id}))),d=z.auth.listLoginMethods.useQuery(),[f,p]=a(null),m=De({onSuccess:()=>void i.userManagement.listExternalIdentities.invalidate(),onError:e=>p(`Remove failed: ${e.message}`)}),h=n(()=>new Map((d.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),[d.data]),g=l.flatMap((e,t)=>u[t]?.data??[]),_=g.map(e=>({...Wt(e,o),kind:h.get(e.provider)??e.provider})),v=async n=>{let r=g.find(e=>Dt(e)===n.id);r!==void 0&&await t({title:e(`access.externalIdentitiesSection.removeSignInLink`,`Remove sign-in link`),message:e(`access.externalIdentitiesSection.willNoLongerBeAble`,`"{{ownerName}}" will no longer be able to sign in with this {{kind}} account.`,{ownerName:n.ownerName,kind:n.kind}),confirmLabel:e(`common.remove`,`Remove`),variant:`danger`})&&(p(null),m.mutate({userId:r.userId,provider:r.provider,subject:r.subject}))};return r(X,{notice:Y(f),onDismissNotice:()=>{p(null)},id:`external-identities`,title:e(`access.externalIdentitiesSection.signInLinks`,`Sign-in links`),icon:le,description:e(`access.externalIdentitiesSection.externalAccountsSingleSignOn`,`External accounts (single sign-on) each user linked to their Dominevo account. Only the owner can link one, from their profile; an admin can remove it.`),children:r(Z,{rows:_,label:`sign-in links`,isLoading:c||u.some(e=>e.isLoading),loadError:u.find(e=>e.isError)?.error?.message??null,emptyText:`No user has linked a sign-in account.`,expiresNone:`—`,action:{label:e(`common.remove`,`Remove`),icon:he,isAvailable:()=>!0,onRun:e=>void v(e),busyId:null,disabled:m.isPending}})})}s();var Xt={key:`access.nouns.linkedApp`};function Zt(e){if(e.type===`category`){let t=e.target??``;return t===`device`?q.t(`access.linkedAppsSection.allDevices`):q.t(`access.linkedAppsSection.allTarget`,{target:t})}if(e.type===`device`)return`device:[${(e.targets??[]).join(`,`)}]`;let t=e;return`${t.type}:${t.target??``}`}function Qt(){let{t:e}=J(),t=T(),i=c(),o=Xe(),[s,l]=a(null),u=()=>void i.invalidateQueries({queryKey:[[`userManagement`,`listOauthSessions`]]}),d=Fe({onSuccess:u,onError:e=>l(`Revoke failed: ${e.message}`)}),f=Tt(Xt,u),p=n(()=>(o.data??[]).map(e=>Kt(e,e.scopes.map(Zt).join(`, `))),[o.data]),m=async n=>{await t({title:e(`access.linkedAppsSection.revokeTheLink`,`Revoke the "{{name}}" link?`,{name:n.name}),message:e(`access.linkedAppsSection.losesAccessForOnIts`,`{{name}} loses access for {{ownerName}} on its next call. Linking it again needs the account-link flow from the start.`,{name:n.name,ownerName:n.ownerName}),confirmLabel:e(`access.linkedAppsSection.revoke`,`Revoke`),variant:`danger`})&&(l(null),d.mutate({id:n.id}))},h=d.isPending?d.variables?.id??null:null;return r(X,{notice:Y(s,f.outcome),onDismissNotice:()=>{l(null),f.dismiss()},id:`linked-apps`,title:e(`access.linkedAppsSection.linkedApps`,`Linked apps`),icon:O,description:e(`access.linkedAppsSection.externalIntegrationsAlexaLinkedTo`,`External integrations (Alexa, …) linked to this hub through OAuth. Revoking one stops that integration on its next call. Already-revoked rows can be selected and removed from the list.`),children:r(Z,{rows:p,label:e(`access.linkedAppsSection.linkedApps2`,`linked apps`),isLoading:o.isLoading,loadError:o.isError?o.error?.message??`Request failed`:null,emptyText:`No linked apps — an integration appears here once it completes the account-link flow.`,expiresNone:`—`,action:{label:e(`access.linkedAppsSection.revoke`,`Revoke`),icon:ie,isAvailable:e=>e.status===`active`||e.status===`revoked`,onRun:e=>void m(e),busyId:h,disabled:d.isPending||f.busy},bulk:{revoke:f,noun:Xt,isSelectable:e=>e.status===`active`||e.status===`revoked`,quickSelect:[{label:e(`access.linkedAppsSection.selectRevoked`,`Select revoked`),match:e=>e.status===`revoked`}]}})})}var $t=5e3;function en(){let{t}=J(),n=z.useUtils(),i=z.auth.cliLoginPending.useQuery(void 0,{refetchInterval:$t}),a=z.auth.cliLoginDeny.useMutation({onSuccess:()=>void n.auth.cliLoginPending.invalidate()}),o=i.data??[];if(o.length===0)return null;let s=Date.now();return e(`div`,{className:`space-y-2 rounded-md border border-border bg-background-elevated p-3`,"data-testid":`pending-terminal-signins`,children:[e(`div`,{className:`flex items-center gap-2 text-xs font-medium text-foreground`,children:[r(de,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`cliLogin.pendingTitle`,`Pending terminal sign-ins`)]}),r(`ul`,{className:`space-y-1`,children:o.map(n=>{let i=_t(n.createdAt,s);return e(`li`,{className:`flex items-center justify-between gap-3 text-xs`,children:[e(`span`,{className:`min-w-0 truncate text-foreground-muted`,children:[n.userAgent??t(`cliLogin.unknownValue`,`Unknown`),` · `,n.ip??t(`cliLogin.unknownValue`,`Unknown`),` · `,i.key===`justNow`?t(`cliLogin.ageNow`,`just now`):i.key===`seconds`?t(`cliLogin.ageSeconds`,`{{count}} s ago`,{count:i.value}):t(`cliLogin.ageMinutes`,`{{count}} min ago`,{count:i.value})]}),r(j,{type:`button`,size:`sm`,variant:`ghost`,disabled:a.isPending,onClick:()=>a.mutate({requestId:n.requestId}),children:t(`cliLogin.notMe`,`Not me`)})]},n.requestId)})}),r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`cliLogin.pendingHint`,`To approve one, open the approval page and type the code the terminal shows.`)})]})}s();var tn={key:`access.nouns.session`};function nn(){let{t}=J(),i=T(),o=z.useUtils(),s=ut(),{user:c}=ot(),l=z.auth.listSessions.useQuery(),[u,d]=a(null),f=()=>void o.auth.listSessions.invalidate(),p=z.auth.revokeSessions.useMutation({onSuccess:f,onError:e=>d(`Sign out failed: ${e.message}`)}),m=Tt(tn,f),h=n(()=>(l.data??[]).map(e=>kt(e,s,{client:e=>Et(e).label,method:wt})),[l.data,s]),g=async e=>{await i({title:t(`access.loginSessionsSection.signOutThisSession`,`Sign out this session`),message:t(`access.loginSessionsSection.onWillHaveToSign`,`{{ownerName}} on {{name}} will have to sign in again.`,{ownerName:e.ownerName,name:e.name}),confirmLabel:t(`access.loginSessionsSection.signOut`,`Sign out`),variant:`danger`})&&(d(null),p.mutate({id:e.id}))};return e(X,{notice:Y(u,m.outcome),onDismissNotice:()=>{d(null),m.dismiss()},id:`login-sessions`,title:t(`access.loginSessionsSection.loginSessions`,`Login sessions`),icon:me,description:t(`access.loginSessionsSection.everyBrowserAndAppSigned`,`Every browser and app signed in to this hub, for every user. Signing one out ends it at once; it has to sign in again. Your own current session is marked and never included in a bulk sign-out.`),children:[r(en,{}),r(Z,{rows:h,label:t(`common.sessionsLabel`),canViewHistory:c?.isAdmin===!0,isLoading:l.isLoading,loadError:l.isError?l.error?.message??`Request failed`:null,emptyText:`No active sessions.`,action:{label:t(`access.loginSessionsSection.signOut`,`Sign out`),icon:F,isAvailable:e=>e.status===`active`,onRun:e=>void g(e),busyId:p.isPending&&p.variables!==void 0&&`id`in p.variables?p.variables.id:null,disabled:p.isPending||m.busy},bulk:{revoke:m,noun:tn,isSelectable:e=>e.status===`active`}})]})}s();var rn=100;function an(){let{user:e}=ot();return e?.isAdmin?r(sn,{}):null}function on(){let{data:e}=Se(),{data:t}=z.auth.listTokens.useQuery(void 0);return n(()=>{let n=new Map;for(let t of e??[])n.set(t.id,t.username);let r=new Map;for(let e of t??[])r.set(e.id,e.label);return{userNameById:n,tokenNameById:r}},[e,t])}function sn(){let{t}=J(),n=z.auth.listAuthAudit.useQuery({limit:rn}),{userNameById:i,tokenNameById:a}=on(),o=n.data??[];return e(`div`,{"data-testid":`auth-audit`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[e(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[r(A,{className:`h-3.5 w-3.5 text-foreground-subtle`}),r(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`auth.authAuditSection.authenticationAudit`,`Authentication audit`)}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:t(`auth.authAuditSection.latest`,{count:rn})})]}),r(`div`,{className:`p-4`,children:n.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),t(`auth.authAuditSection.loadingAuditTrail`,`Loading audit trail…`)]}):n.isError?e(`div`,{className:`text-[11px] text-danger`,children:[t(`auth.authAuditSection.couldNotLoadTheAudit`,`Could not load the audit trail:`),` `,n.error?.message??t(`auth.authAuditSection.requestFailed`,`Request failed`)]}):o.length===0?e(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center space-y-1`,children:[r(`div`,{children:t(`auth.authAuditSection.noAuthenticationEventsRecordedYet`,`No authentication events recorded yet.`)}),r(`div`,{className:`text-[11px] text-foreground-subtle/90`,children:t(`auth.authAuditSection.thisTrailRecordsAdminToken`,`This trail records admin-token create/use/revoke, trusted-network 2FA skips, and credential revokes (including single share-link revoke). Browser password logins are not listed here.`)})]}):r(`ul`,{className:`divide-y divide-border rounded-md border border-border max-h-[420px] overflow-y-auto`,children:o.map(e=>r(cn,{record:e,userName:e.userId===void 0?null:i.get(e.userId)??e.userId,tokenNameById:a},e.id))})})]})}function cn({record:t,userName:n,tokenNameById:i}){let a=Gt(t,i);return e(`li`,{"data-testid":`auth-audit-row`,className:`px-3 py-2 text-xs space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[r(`span`,{className:`font-medium text-foreground`,children:a.title}),r(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:Ct(t.at)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[n!==null&&r(`span`,{className:`text-foreground`,children:n}),t.ip!==void 0&&r(`span`,{className:`font-mono`,children:t.ip}),a.details.map(e=>r(`span`,{className:`font-mono`,children:e},e))]})]})}s();function ln(e){let{ids:t,answered:r,legacyGroupParam:i=null,groupFirst:a}=e,[o]=at(),s=o.get(ht),c=i===null?null:o.get(i),l=o.get(gt),u=n(()=>mt({ids:t,requested:s,answered:r,legacyGroup:c,...a===void 0?{}:{groupFirst:a}}),[t,s,r,c,a]),d=n(()=>(e,t)=>`?${vt(o,e,i,t??null).toString()}`,[o,i]);return{...u,requestedSection:l,hrefFor:d}}s();var Q={loginSessions:`login-sessions`,linkedApps:`linked-apps`,tokens:`tokens`,scopedTokens:`scoped-tokens`,adminTokens:`admin-tokens`,shareLinks:`share-links`,externalIdentities:`external-identities`,audit:`auth-audit`},un={[Q.scopedTokens]:Q.tokens,[Q.adminTokens]:Q.tokens,[Q.shareLinks]:Q.tokens};function dn(){return[{id:Q.loginSessions,label:q.t(`system.access.loginSessions`,`Login sessions`),icon:me,render:()=>r(nn,{})},{id:Q.linkedApps,label:q.t(`system.access.linkedApps`,`Linked apps`),icon:O,render:()=>r(Qt,{})},{id:Q.tokens,label:q.t(`system.access.tokens`,`Tokens`),icon:P,render:({createRequested:e,onCreateConsumed:t})=>r(Pt,{headerOwnsCreate:!0,createRequested:e,onCreateConsumed:t})},{id:Q.externalIdentities,label:q.t(`system.access.signInLinks`,`Sign-in links`),icon:le,render:()=>r(Yt,{})},{id:Q.audit,label:q.t(`system.access.audit`,`Audit`),icon:A,render:()=>r(an,{})}]}function fn({createRequested:t=!1,onCreateConsumed:i}){let{t:a}=J(),o=n(()=>dn(),[]),s=ln({ids:n(()=>o.map(e=>e.id),[o]),answered:!0}),c=rt(),[l]=at(),u=l.get(`integration`),d=u===null?void 0:un[u];if(d!==void 0){let e=new URLSearchParams(l);return e.set(`integration`,d),r(nt,{to:`?${e.toString()}`,replace:!0})}let f=o.find(e=>e.id===s.selectedId)??o[0];return e(`div`,{className:`flex flex-col gap-3`,"data-testid":`access-page`,children:[r(Ge,{appearance:`pills`,value:f?.id??Q.loginSessions,onValueChange:e=>{c(`?${vt(l,e,null,null).toString()}`)},children:r(ze,{"aria-label":a(`system.access.credentialKinds`,`Credential kinds`),children:o.map(t=>e(et,{value:t.id,"data-testid":`access-kind-${t.id}`,children:[r(t.icon,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),t.label]},t.id))})}),f===void 0?null:r(`div`,{role:`region`,"aria-label":f.label,"data-testid":`access-kind-body`,children:f.render({createRequested:t&&f.id===Q.tokens,onCreateConsumed:i??(()=>void 0)})},f.id)]})}function pn(t,n){if(t===Q.tokens)return e(j,{size:`sm`,type:`button`,"data-testid":`access-new-token`,onClick:n,children:[r(P,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),q.t(`system.access.newToken`,`New token`)]})}function mn(){let[e,t]=a(!1);return{createRequested:e,requestCreate:()=>t(!0),clearCreate:()=>t(!1)}}function hn(){let{t}=J();return e(`div`,{className:`space-y-3 sm:space-y-4`,children:[r(bt,{functionCap:`login-method`,icon:ue,title:t(`system.authentication.connectionsTitle`,`Sign-in connections`),subtitle:t(`system.authentication.connectionsSubtitle`,`Identity providers that sign users in. Each connection has its own id, which cannot be changed later.`),emptyTitle:t(`system.authentication.connectionsEmptyTitle`,`No sign-in connections`),emptyDescription:t(`system.authentication.connectionsEmptyDescription`,`Add a connection to let users sign in through an identity provider.`),addLabel:t(`system.authentication.addConnection`,`Add connection`),install:{capability:`login-method`,label:t(`system.authentication.sectionInstall`,`Add provider`)},typedId:()=>({pattern:lt})}),r(_n,{})]})}var gn=qt;function _n(){let{t}=J();return r(R,{headingId:`authentication-policy`,title:t(`system.authentication.policyTitle`,`Sign-in policy`),icon:u,children:e(`div`,{className:f,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:t(`system.authentication.localAlwaysOn`,`Username and password sign-in is always on and cannot be turned off. It is not a connection, so it has no row above.`)}),r(`p`,{className:`text-xs text-foreground-subtle`,children:r(st,{i18nKey:`system.authentication.totpNote`,components:{access:r(it,{to:`/system/my-access?tab=sign-in`,className:`underline text-primary`}),users:r(it,{to:`/system/identity?tab=users`,className:`underline text-primary`})}})}),r(Jt,{sectionIds:[gn],hideSectionChrome:!0,emptyMessage:t(`system.authentication.policyUnavailable`,`Not available — the addon that owns these settings did not answer.`)})]})})}function vn({isPending:t,error:n,what:i,onRetry:a,children:o}){let{t:s}=J();return t?e(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,role:`status`,"data-testid":`query-pending`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),s(`certificates.queryBody.reading`,{what:i})]}):n===null?o:r(U,{title:s(`certificates.queryBody.couldNotRead`,`Could not read {{what}}`,{what:i}),message:n.message.length>0?n.message:s(`certificates.queryBody.requestFailed`,`Request failed`),onRetry:a})}function yn(){let{t}=J(),n=z.deviceCredentials.getDeviceCaStatus.useQuery({}),i=n.data;return r(X,{id:`device-ca`,title:t(`certificates.deviceCaCard.deviceCertificateAuthority`,`Device certificate authority`),icon:u,description:t(`certificates.deviceCaCard.signsTheCertificateEachPaired`,`Signs the certificate each paired device holds. It is created the first time a device is paired.`),children:r(vn,{isPending:n.isPending,error:n.error,what:`the device CA`,onRetry:()=>void n.refetch(),children:i!==void 0&&e(`div`,{className:`space-y-1`,"data-testid":`device-ca-status`,children:[e(G,{label:t(`certificates.deviceCaCard.state`,`State`),children:[i.state===`ready`&&r(I,{variant:`success`,children:t(`certificates.deviceCaCard.ready`,`Ready`)}),i.state===`absent`&&r(I,{variant:`default`,children:t(`certificates.deviceCaCard.notCreatedYet`,`Not created yet`)}),i.state===`unavailable`&&r(I,{variant:`danger`,children:t(`certificates.deviceCaCard.unavailable`,`Unavailable`)})]}),i.state===`ready`&&e(l,{children:[r(G,{label:t(`certificates.deviceCaCard.subject`,`Subject`),valueClassName:`font-mono`,children:i.subject}),r(G,{label:t(`certificates.deviceCaCard.fingerprintSha256`,`Fingerprint (SHA-256)`),valueClassName:`font-mono`,children:i.fingerprintSha256}),r(G,{label:t(`certificates.deviceCaCard.validUntil`,`Valid until`),children:i.validTo})]}),i.state===`unavailable`&&r(G,{label:t(`certificates.deviceCaCard.reason`,`Reason`),children:r(`span`,{className:`text-danger`,children:i.reason})})]})})})}s();function bn(){let{t}=J(),n=z.useUtils(),i=z.deviceCredentials.getDeviceCertificateSettings.useQuery({}),[o,s]=a(null),[c,u]=a(null),d=z.deviceCredentials.setDeviceCertificateSettings.useMutation({onSuccess:()=>{s(null),u(null),n.deviceCredentials.getDeviceCertificateSettings.invalidate()},onError:e=>s(`Could not save: ${e.message}`)});return r(vn,{isPending:i.isPending,error:i.error,what:`the enrollment setting`,onRetry:()=>void i.refetch(),children:i.data!==void 0&&e(l,{children:[e(G,{label:t(`certificates.deviceSettingsRow.usersCanEnrollTheirOwn`,`Users can enroll their own devices`),actions:r(ye,{checked:(c??i.data.selfEnrollment)===`allowed`,disabled:d.isPending,"aria-label":t(`certificates.deviceSettingsRow.usersCanEnrollTheirOwn`,`Users can enroll their own devices`),onCheckedChange:e=>u(e?`allowed`:`disabled`)}),children:[r(`span`,{className:`text-[11px] text-foreground-subtle`,children:(c??i.data.selfEnrollment)===`allowed`?t(`certificates.deviceSettingsRow.allowedAUserSignedIn`,`Allowed - a user signed in on a phone can keep it signed in. Pairing by QR works either way.`):t(`certificates.deviceSettingsRow.disabledOnlyAnAdminCan`,`Disabled - only an admin can pair a device, with a QR code.`)}),o!==null&&r(`span`,{className:`block text-[11px] text-danger`,children:o})]}),r(_,{pendingCount:+(c!==null&&c!==i.data.selfEnrollment),saving:d.isPending,onSave:()=>c!==null&&d.mutate({selfEnrollment:c}),onDiscard:()=>{u(null),s(null)}})]})})}s();function xn(e){let[t,n]=a(()=>Date.now());return i(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}s();var Sn=80,Cn=208;function wn({open:t,users:n,onClose:i,onPaired:o}){let{t:s}=J(),c=z.deviceCredentials.startEnrollment.useMutation({onSuccess:o}),[l,u]=a(``),[d,f]=a(``),p=l===``?n[0]?.id??``:l,m=c.data,h=()=>{c.reset(),f(``),i()};return r(Ue,{open:t,onClose:h,title:s(`certificates.pairDeviceDialog.pairADevice`,`Pair a device`),icon:g,width:`md`,testId:`pair-device-dialog`,error:c.isError?c.error.message:null,footer:m===void 0?e(j,{type:`button`,onClick:()=>{let e=d.trim();p===``||e===``||c.mutate({userId:p,deviceName:e})},disabled:c.isPending||p===``||d.trim()===``,children:[c.isPending&&r(k,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),s(`certificates.pairDeviceDialog.createPairingCode`,`Create pairing code`)]}):r(j,{type:`button`,variant:`outline`,onClick:h,children:s(`certificates.pairDeviceDialog.done`,`Done`)}),children:m===void 0?e(`div`,{className:`space-y-3`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:s(`certificates.pairDeviceDialog.createsAOneTimeCode`,`Creates a one-time code for a phone you hold. Scan it with the Dominevo app on that phone; the phone then stays signed in as the chosen user until you revoke it.`)}),r(K,{label:s(`certificates.pairDeviceDialog.user`,`User`),required:!0,children:r(x,{value:p,onChange:e=>u(e.target.value),options:n.map(e=>({value:e.id,label:e.username}))})}),r(K,{label:s(`certificates.pairDeviceDialog.deviceName`,`Device name`),required:!0,description:s(`certificates.pairDeviceDialog.howThisPhoneIsListed`,`How this phone is listed, e.g. Anna's iPhone.`),children:r(oe,{value:d,maxLength:Sn,onChange:e=>f(e.target.value),placeholder:s(`certificates.pairDeviceDialog.annaSIphone`,`Anna's iPhone`),autoFocus:!0})})]}):r(Tn,{enrollUrl:m.enrollUrl,expiresAt:m.expiresAt,hubKnown:m.hubOrigin!==null,onRestart:()=>c.reset()})})}function Tn({enrollUrl:t,expiresAt:n,hubKnown:i,onRestart:a}){let{t:o}=J(),s=zt(n,xn(1e3));return r(`div`,{className:`space-y-3`,"data-testid":`pair-issued`,children:e(`div`,{className:`flex flex-col items-center gap-3 sm:flex-row sm:items-start`,children:[r(`div`,{className:s.expired?`opacity-30`:void 0,children:r(Pe,{value:t,size:Cn,alt:o(`certificates.pairDeviceDialog.enrollmentQrCode`,`Enrollment QR code`)})}),e(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`certificates.pairDeviceDialog.openTheDominevoAppOn`,`Open the Dominevo app on the phone and scan this code. It works once.`)}),r(`div`,{className:`text-sm font-semibold tabular-nums text-foreground`,role:`timer`,"data-testid":`pair-countdown`,children:s.expired?o(`certificates.pairDeviceDialog.expiredCreateANewCode`,`Expired - create a new code`):o(`certificates.pairDeviceDialog.expiresIn`,`Expires in {{label}}`,{label:s.label})}),e(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[r(`code`,{className:`min-w-0 flex-1 select-all break-all font-mono text-[11px] text-foreground`,children:t}),r(we,{value:t,srLabel:`Enrollment link`})]}),!i&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[r(y,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),r(`span`,{children:o(`certificates.pairDeviceDialog.theHubCouldNotName`,`The hub could not name an address for this link, so the app must already know it.`)})]}),s.expired&&r(j,{type:`button`,variant:`outline`,size:`sm`,onClick:a,children:o(`certificates.pairDeviceDialog.newCode`,`New code`)})]})]})})}s();var En={key:`access.nouns.device`};function Dn({pairOpen:t,onPairClose:i}){let{t:o}=J(),s=T(),c=b(),l=z.useUtils(),u=z.deviceCredentials.listDeviceCredentials.useQuery({includeRevoked:!0}),f=Se(),[p,m]=a(null),[h,_]=a(null),v=()=>void l.deviceCredentials.listDeviceCredentials.invalidate(),y=e=>t=>{_(null),m(`${e} failed: ${t.message}`)},x=()=>{_(null),v()},S=z.deviceCredentials.revokeDeviceCredential.useMutation({onSuccess:x}),C=z.deviceCredentials.deleteDeviceCredential.useMutation({onSuccess:x}),w=z.deviceCredentials.renameDeviceCredential.useMutation({onSuccess:x,onError:y(`Rename`)}),D=St(En,e=>S.mutateAsync({id:e}),v),O=D.busy||h!==null,ee=n(()=>(u.data??[]).map(Rt),[u.data]),k=async e=>{m(null),await s({title:o(`certificates.devicesCard.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:o(`certificates.devicesCard.sDeviceStopsSigningIn`,`{{ownerName}}'s device stops signing in at once and its open sessions end. To use it again it has to be paired anew. This cannot be undone.`,{ownerName:e.ownerName}),confirmLabel:o(`certificates.devicesCard.revoke2`,`Revoke`),variant:`danger`,action:async()=>{_(e.id);try{await S.mutateAsync({id:e.id})}finally{_(null)}}})},te=async e=>{m(null),await s({title:o(`certificates.devicesCard.delete`,`Delete "{{name}}"?`,{name:e.name}),message:o(`certificates.devicesCard.isRemovedFromTheList`,`{{name}} is removed from the list. The audit trail keeps the revocation.`,{name:e.name}),confirmLabel:o(`common.delete`,`Delete`),variant:`danger`,action:async()=>{_(e.id);try{let t=await C.mutateAsync({id:e.id});if(t.result===`deleted`)return;throw Error(t.result===`live`?`Only a revoked device can be deleted: revoke it first.`:`That device no longer exists.`)}finally{_(null)}}})},A=async e=>{let t=(await c({title:o(`certificates.devicesCard.renameDevice`,`Rename device`),label:o(`certificates.devicesCard.deviceName`,`Device name`),defaultValue:e.name,confirmLabel:o(`certificates.devicesCard.rename`,`Rename`)}))?.trim()??``;t===``||t===e.name||(m(null),_(e.id),w.mutate({id:e.id,deviceName:t}))},ne={label:o(`certificates.devicesCard.revoke2`,`Revoke`),icon:E,isAvailable:Ot,onRun:e=>void k(e),busyId:S.isPending?h:null,disabled:O},re=[{label:o(`certificates.devicesCard.rename`,`Rename`),icon:d,tone:`neutral`,isAvailable:()=>!0,onRun:e=>void A(e),busyId:w.isPending?h:null,disabled:O},{label:o(`common.delete`,`Delete`),icon:ie,isAvailable:Ft,onRun:e=>void te(e),busyId:C.isPending?h:null,disabled:O}];return e(X,{id:`devices`,title:o(`certificates.devicesCard.devices`,`Devices`),icon:g,description:o(`certificates.devicesCard.phonesThatStaySignedIn`,`Phones that stay signed in with a certificate instead of a login. Revoking one signs it out at once; it has to be paired again.`),notice:Y(p,D.outcome),onDismissNotice:()=>{m(null),D.dismiss()},children:[r(bn,{}),r(Z,{rows:ee,label:o(`certificates.devicesCard.label`),isLoading:u.isPending,loadError:u.error===null?null:u.error.message||`Request failed`,emptyText:`No devices paired yet.`,expiresNone:`—`,action:ne,extraActions:re,bulk:{revoke:D,noun:En,isSelectable:Ot}}),r(wn,{open:t,users:f.data??[],onClose:i,onPaired:v})]})}var On=/-----BEGIN CERTIFICATE-----[\s\S]+?-----END CERTIFICATE-----/,kn=/-----BEGIN ((?:RSA |EC |ENCRYPTED )?PRIVATE KEY)-----[\s\S]+?-----END \1-----/,An={certificate:`.pem,.crt,.cer`,privateKey:`.pem,.key`,ca:`.pem,.crt,.cer`};function jn(e,t){if(t.trim()===``)return null;if(e===`privateKey`){let e=kn.exec(t);return e===null?On.test(t)?q.t(`helpers.pemFile.isCert`):q.t(`helpers.pemFile.notKey`):e[1]===`ENCRYPTED PRIVATE KEY`?q.t(`helpers.pemFile.encrypted`):null}return On.test(t)?e===`certificate`&&kn.test(t)?q.t(`helpers.pemFile.certHasKey`):null:kn.test(t)?q.t(`helpers.pemFile.isKey`):q.t(`helpers.pemFile.notCert`)}function Mn(e){return e.text()}s();function Nn({kind:n,label:i,value:o,onChange:s,rows:c=6}){let{t:l}=J(),u=t(null),[d,f]=a(null),[p,m]=a(null),h=p??jn(n,o),g=`pem-${n}`,_=async e=>{let t=e.target.files?.[0];if(e.target.value=``,t!==void 0){f(t.name);try{let e=await Mn(t);m(null),s(e)}catch(e){m(`Could not read ${t.name}: ${e instanceof Error?e.message:String(e)}`)}}};return e(`div`,{className:`space-y-1`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[r(`label`,{htmlFor:g,className:`text-[11px] text-foreground-subtle`,children:i}),e(`div`,{className:`flex min-w-0 items-center gap-2`,children:[d!==null&&r(`span`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,"data-testid":`${g}-file-name`,children:d}),r(tt,{ref:u,accept:An[n],onChange:e=>void _(e),className:`hidden`,"data-testid":`${g}-file`}),e(j,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>u.current?.click(),children:[r(fe,{className:`mr-1 h-3 w-3`}),l(`system.pemField.chooseFile`,`Choose file`)]})]})]}),r(ke,{id:g,value:o,onChange:e=>{f(null),m(null),s(e.target.value)},rows:c,"aria-invalid":h!==null,className:`w-full rounded border border-border bg-surface px-2 py-1 font-mono text-[11px]`}),h!==null&&r(`p`,{className:`text-[11px] text-danger`,role:`alert`,children:h})]})}s();var Pn=30;function Fn(e){let t=Date.parse(e);return!Number.isNaN(t)&&Date.now()-t<Pn*864e5}function In(e){if(e===null||e===``)return`—`;let t=e.replace(/:/g,``);return t.length<=16?e:`${t.slice(0,8)}…${t.slice(-8)}`}function Ln(){let{t}=J(),n=c(),i=Be(void 0,{refetchInterval:15e3}),o=Oe({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),s=Ae({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),l=ve({onSuccess:()=>void n.invalidateQueries({queryKey:[[`localNetwork`]]})}),u=Je({onSuccess:()=>{m(!1),g(``),y(``),x(``),n.invalidateQueries({queryKey:[[`localNetwork`]]})}}),d=i.data,[p,m]=a(!1),[h,g]=a(``),[_,y]=a(``),[b,x]=a(``),S=()=>{if(!d?.caCertPem)return;let e=new Blob([d.caCertPem],{type:`application/x-pem-file`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`dominevo-ca.crt`,n.click(),URL.revokeObjectURL(t)},C=d?.mode===`uploaded`?`Uploaded`:d?.mode===`generated`?`Generated local CA`:`TLS disabled`;return r(R,{headingId:`local-access-certificate`,title:t(`system.localAccess.certificate`,`Certificate`),icon:v,children:e(`div`,{className:`${f} space-y-3`,children:[i.isError&&r(`p`,{className:`text-xs text-danger`,children:t(`system.localAccess.couldNotReadTlsStatus`,`Could not read TLS status.`)}),d?.reissueError&&r(U,{variant:`warning`,title:t(`system.localAccess.certificateReissue`,`Certificate reissue`),message:d.reissueError}),d?.restartRequired&&r(U,{variant:`warning`,title:t(`system.localAccess.restartRequired`,`Restart required`),message:t(`system.localAccess.theHttpsListenerStillServes`,`The HTTPS listener still serves the previous certificate. Restart the hub to apply it.`)}),d?.caMissing===!0&&r(U,{variant:`warning`,title:t(`system.localAccess.caMissingTitle`,`CA missing - devices cannot trust this hub`),message:t(`system.localAccess.caMissingBody`,"The uploaded certificate was not issued by a public CA and no CA was stored with it, so Download CA has nothing to hand out. Upload the certificate again together with its CA (for mkcert, the rootCA.pem in the folder `mkcert -CAROOT` prints).")}),d?.caReplacedAt!=null&&Fn(d.caReplacedAt)&&r(U,{variant:`warning`,title:t(`system.localAccess.caReplacedTitle`,`The local CA was replaced - re-install it on your devices`),message:t(`system.localAccess.caReplacedBody`,`The previous local CA had no name constraints: if its key ever leaked it could vouch for any website. The hub now uses a CA limited to private addresses and local names. Download it again and trust it on every phone and computer that used the old one (replaced {{when}}).`,{when:new Date(d.caReplacedAt).toLocaleString()})}),e(`dl`,{className:`grid grid-cols-1 gap-2 text-xs sm:grid-cols-2`,children:[e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.mode`,`Mode`)}),r(`dd`,{className:`font-medium`,children:C})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.validTo`,`Valid to`)}),r(`dd`,{className:`font-mono`,children:d?.validTo?new Date(d.validTo).toLocaleString():`—`})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.leafSha256`,`Leaf SHA-256`)}),r(`dd`,{className:`font-mono`,title:d?.leafFingerprintSha256??void 0,children:In(d?.leafFingerprintSha256??null)})]}),d?.storedUpload!=null&&e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.storedUpload`,`Stored upload`)}),r(`dd`,{className:`font-medium`,children:t(`system.localAccess.storedUploadValue`,`valid to {{validTo}}, {{ca}}`,{validTo:new Date(d.storedUpload.validTo).toLocaleDateString(),ca:d.storedUpload.hasCa?t(`system.localAccess.storedUploadWithCa`,`with its CA`):t(`system.localAccess.storedUploadNoCa`,`no CA`)})})]}),e(`div`,{children:[r(`dt`,{className:`text-foreground-subtle`,children:t(`system.localAccess.caSha256`,`CA SHA-256`)}),r(`dd`,{className:`font-mono`,title:d?.caFingerprintSha256??void 0,children:d?.mode===`uploaded`&&d.caFingerprintSha256===null?r(`span`,{className:`font-sans text-foreground-subtle`,children:t(`system.localAccess.issuerNotIncludedInThe`,`Issuer not included in the upload (not the local CA)`)}):In(d?.caFingerprintSha256??null)})]})]}),d&&d.sans.length>0&&r(`div`,{className:`flex flex-wrap gap-1`,children:d.sans.map(e=>r(`span`,{className:`rounded border border-border bg-surface px-1.5 py-0.5 font-mono text-[10px] text-foreground-subtle`,children:e},e))}),e(`div`,{className:`flex flex-wrap gap-2`,children:[r(B,{label:t(`system.localAccess.regenerate`,`Regenerate`),title:t(`system.localAccess.issueANewLeaf`,`Issue a new leaf?`),description:t(`system.localAccess.issuesANewLeafUnder`,`Issues a new leaf under the current local CA. Clients that trust the CA keep working. The HTTPS listener reloads.`),confirmLabel:t(`system.localAccess.regenerate`,`Regenerate`),disabled:d?.mode===`uploaded`||o.isPending,action:()=>o.mutateAsync({})}),r(j,{size:`sm`,variant:`outline`,onClick:()=>m(e=>!e),children:t(`system.localAccess.upload`,`Upload`)}),d?.caCertPem&&r(j,{size:`sm`,variant:`outline`,onClick:S,children:t(`system.localAccess.downloadCa`,`Download CA`)}),d?.mode===`uploaded`&&r(B,{label:t(`system.localAccess.revertToGenerated`,`Revert to generated`),title:t(`system.localAccess.revertTitle`,`Switch back to the generated certificate?`),description:t(`system.localAccess.keepsTheUploadedPair`,`Returns to the generated local CA. The uploaded certificate and its CA stay stored here; you can select them again.`),confirmLabel:t(`system.localAccess.revert`,`Revert`),disabled:s.isPending,action:()=>s.mutateAsync({})}),d?.mode===`generated`&&d.storedUpload!=null&&r(B,{label:t(`system.localAccess.useUploaded`,`Use uploaded certificate`),title:t(`system.localAccess.useUploadedTitle`,`Serve the stored upload again?`),description:t(`system.localAccess.useUploadedDescription`,`The stored uploaded certificate replaces the generated one on the HTTPS listener. The generated certificate stays stored.`),confirmLabel:t(`system.localAccess.useUploaded`,`Use uploaded certificate`),disabled:l.isPending,action:()=>l.mutateAsync(void 0)})]}),p&&e(`div`,{className:`space-y-2 border-t border-border pt-3`,children:[r(Nn,{kind:`certificate`,label:t(`system.localAccess.certificateOrFullChainPem`,`Certificate or full chain (PEM)`),value:h,onChange:g}),r(Nn,{kind:`privateKey`,label:t(`system.localAccess.privateKeyPem`,`Private key (PEM)`),value:_,onChange:y}),r(Nn,{kind:`ca`,label:t(`system.localAccess.caPemRequired`,`CA (PEM) - required unless the certificate comes from a public CA`),value:b,onChange:x,rows:4}),r(j,{size:`sm`,disabled:!h.trim()||!_.trim()||jn(`certificate`,h)!==null||jn(`privateKey`,_)!==null||jn(`ca`,b)!==null||u.isPending,onClick:()=>u.mutate({certPem:h,keyPem:_,...b.trim()?{caPem:b}:{}}),children:t(`system.localAccess.saveCertificate`,`Save certificate`)}),u.isError&&r(`p`,{className:`text-xs text-danger`,children:u.error instanceof Error?u.error.message:t(`system.localAccess.uploadFailed`,`Upload failed`)})]})]})})}var Rn={ok:`text-foreground-subtle`,soon:`text-warning`,expired:`text-danger`,unknown:`text-foreground-subtle`};function zn(e){let t=e.find(e=>e.isHub);return t?.https.kind===`served`?t.https.status.caFingerprintSha256:null}function Bn({https:t,mesh:n,now:i}){let{t:a}=J(),o=Be().data?.caCertPem??``,s=()=>{if(o===``)return;let e=URL.createObjectURL(new Blob([o],{type:`application/x-pem-file`})),t=document.createElement(`a`);t.href=e,t.download=`dominevo-ca.crt`,t.click(),URL.revokeObjectURL(e)},c=n?.ca,l=c?.state===`ready`?Date.parse(c.validTo):null,u=n?.listener;return e(`div`,{className:`space-y-1`,"data-testid":`ca-strip`,children:[r(G,{label:a(`certificates.caStrip.localHttpsCaSha256`,`Local HTTPS CA (SHA-256)`),valueClassName:`font-mono`,children:e(`span`,{className:`flex flex-wrap items-center gap-2`,children:[zn(t)??`—`,o!==``&&e(j,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:[r(p,{className:`h-3 w-3`,"aria-hidden":!0}),a(`certificates.caStrip.downloadCa`,`Download CA`)]})]})}),r(G,{label:a(`certificates.caStrip.clusterCaSha256`,`Cluster CA (SHA-256)`),valueClassName:`font-mono`,children:c===void 0?`—`:c.state===`ready`?c.fingerprintSha256:r(`span`,{className:`text-danger`,children:a(`certificates.caStrip.unavailable`,{reason:c.reason})})}),c?.state===`ready`&&e(G,{label:a(`certificates.caStrip.clusterCaValidUntil`,`Cluster CA valid until`),children:[c.validTo,l!==null&&!Number.isNaN(l)&&e(`span`,{className:`ml-2 text-[10px] ${Rn[Ut(l,i)]}`,children:[`(`,At(l,i),`)`]})]}),u!==void 0&&e(G,{label:a(`certificates.caStrip.nodeListener`,`Node listener`),children:[u.state===`open`&&r(I,{variant:`success`,children:a(`certificates.caStrip.open`,`Open`)}),u.state===`not-started`&&r(I,{variant:`default`,children:a(`certificates.caStrip.notStarted`,`Not started`)}),u.state===`closed`&&e(`span`,{className:`text-danger`,children:[a(`certificates.caStrip.closedSince`,{when:jt(u.since)}),` `,u.reason]})]}),n!==void 0&&!n.registryAvailable&&e(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[r(y,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-warning`,"aria-hidden":!0}),r(`span`,{children:a(`certificates.caStrip.theCertificateRegistryIsNot`,`The certificate registry is not up, so the node list below is incomplete.`)})]})]})}function Vn(e,t){let n=new Set;for(let t of e)n.add(t.nodeId);for(let e of t?.nodes??[])n.add(e.nodeId);return[...n].map(n=>{let r=e.find(e=>e.nodeId===n)??null,i=t?.nodes.find(e=>e.nodeId===n)??null;return{nodeId:n,isHub:r?.isHub??n===`hub`,online:r?.online??i?.online??!1,https:r,mesh:i}}).toSorted((e,t)=>Number(t.isHub)-Number(e.isHub)||e.nodeId.localeCompare(t.nodeId))}function Hn(e){return e.isHub?q.t(`helpers.nodesModel.hubReissued`):e.mesh===null?q.t(`helpers.nodesModel.noCertRecorded`):e.online?null:q.t(`helpers.certificateModel.nodeOffline`)}function Un(e){return e.isHub||e.mesh===null?Hn(e):null}var Wn={ok:`text-foreground-subtle`,soon:`text-warning`,expired:`text-danger`,unknown:`text-foreground-subtle`},Gn={enroll:`Issued at enrollment`,renewal:`Issued by a renewal`,boot:`Issued at boot`,pairing:`Issued at pairing`,observed:`Observed on its connection`},Kn={uploaded:`Uploaded`,generated:`Generated`,disabled:`Disabled`};function qn(e){let t=e.https?.https;return t?.kind===`served`?Vt(t.status.validTo):null}function Jn({ms:t,now:n}){return t===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`div`,{children:[r(`div`,{children:jt(t)}),r(`div`,{className:`text-[10px] ${Wn[Ut(t,n)]}`,children:At(t,n)})]})}function Yn({row:t}){let{t:n}=J(),i=t.https?.https;return i===void 0?r(`span`,{className:`text-foreground-subtle`,children:`—`}):i.kind===`served`?e(`div`,{title:i.status.leafFingerprintSha256??``,children:[r(I,{variant:`success`,className:`text-[10px]`,children:n(`certificates.nodesColumns.served`,`Served`)}),r(`span`,{className:`ml-1.5 text-[10px] text-foreground-subtle`,children:Kn[i.status.mode]}),r(`div`,{className:`mt-1 font-mono text-[10px] text-foreground-subtle`,children:Bt(i.status.leafFingerprintSha256)}),i.status.sans.length>0&&r(`div`,{className:`mt-0.5 max-w-[14rem] truncate font-mono text-[10px] text-foreground-subtle`,title:i.status.sans.join(`, `),children:i.status.sans.join(`, `)})]}):e(`div`,{className:`max-w-[16rem]`,children:[r(I,{variant:i.kind===`unreadable`?`danger`:`warning`,className:`text-[10px]`,children:i.kind===`unreadable`?n(`certificates.nodesColumns.unreadable`,`Unreadable`):n(`certificates.nodesColumns.notServed`,`Not served`)}),r(`div`,{className:`mt-1 whitespace-normal text-[10px] text-foreground-subtle`,children:i.reason})]})}function Xn({row:t}){let{t:n}=J(),i=t.mesh?.current??null;if(i===null)return r(`span`,{className:`text-foreground-subtle`,children:n(`certificates.nodesColumns.noneRecorded`,`None recorded`)});let a=t.mesh?.history.length??0;return e(`div`,{children:[r(`div`,{className:`font-mono text-[11px]`,title:i.serial,children:Lt(i.serial)}),r(`div`,{className:`font-mono text-[10px] text-foreground-subtle`,title:i.fingerprintSha256,children:Bt(i.fingerprintSha256)}),e(`div`,{className:`text-[10px] text-foreground-subtle`,children:[Gn[i.issuedVia],a>0?` · ${n(`certificates.nodesColumns.earlier`,{count:a})}`:``]})]})}function Zn({row:e}){let{t}=J(),n=e.mesh?.presentingCurrent??null;return n===null?r(`span`,{className:`text-foreground-subtle`,children:e.online?`—`:t(`certificates.nodesColumns.offline`,`Offline`)}):n?r(I,{variant:`success`,className:`text-[10px]`,children:t(`common.yes`,`Yes`)}):r(I,{variant:`warning`,className:`text-[10px]`,children:t(`certificates.nodesColumns.noPresentsAnother`,`No - presents another`)})}function Qn(t){let n=t.icon;return e(j,{type:`button`,variant:`ghost`,size:`sm`,className:t.danger?`text-danger hover:bg-danger/10`:void 0,disabled:t.reason!==null||t.busy,title:t.reason??void 0,"aria-label":t.ariaLabel,onClick:t.onClick,children:[t.spinning?r(k,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):r(n,{className:`h-3 w-3`,"aria-hidden":!0}),t.label]})}function $n({reasons:t}){let{t:n}=J();return e(Ve,{className:`inline-block`,children:[r(Ye,{children:r(`span`,{className:`cursor-help text-[11px] text-foreground-subtle`,"data-testid":`hub-managed-note`,children:n(`certificates.nodesColumns.managedByTheHub`,`Managed by the hub`)})}),r(We,{children:r(`ul`,{className:`max-w-xs space-y-1 whitespace-normal text-left text-[11px]`,children:t.map(e=>r(`li`,{children:e},e))})})]})}function er({row:t,o:n}){let{t:i}=J(),a=t.https===null?`No HTTPS inventory for this node.`:Mt(t.https).reason,o=Hn(t),s=Un(t),c=e=>n.running?.nodeId===t.nodeId&&n.running.action===e,l=e=>!t.isHub||e===null,u=[a,o,s].filter((e,t,n)=>e!==null&&n.indexOf(e)===t);return e(`div`,{className:`flex w-44 flex-col items-end gap-1`,children:[e(`div`,{className:`flex flex-col items-end gap-0.5`,children:[l(a)&&r(Qn,{label:i(`certificates.nodesColumns.renewHttps`,`Renew HTTPS`),ariaLabel:i(`certificates.nodesColumns.renewTheCertificateOn`,`Renew the certificate on {{nodeId}}`,{nodeId:t.nodeId}),icon:w,reason:a,busy:n.busy,spinning:c(`renew-https`),danger:!1,onClick:()=>n.onRenewHttps(t)}),l(o)&&r(Qn,{label:c(`renew-identity`)?i(`certificates.nodesColumns.renewing`,`Renewing…`):i(`certificates.nodesColumns.renewIdentity`,`Renew identity`),ariaLabel:i(`certificates.nodesColumns.renewTheClusterCertificateOf`,`Renew the cluster certificate of {{nodeId}}`,{nodeId:t.nodeId}),icon:w,reason:o,busy:n.busy,spinning:c(`renew-identity`),danger:!1,onClick:()=>n.onRenewIdentity(t)}),l(s)&&r(Qn,{label:i(`certificates.nodesColumns.revokeIdentity`,`Revoke identity`),ariaLabel:i(`certificates.nodesColumns.revokeTheClusterCertificateOf`,`Revoke the cluster certificate of {{nodeId}}`,{nodeId:t.nodeId}),icon:E,reason:s,busy:n.busy,spinning:c(`revoke-identity`),danger:!0,onClick:()=>n.onRevokeIdentity(t)})]}),t.isHub&&u.length>0&&r($n,{reasons:u}),!t.isHub&&a!==null&&t.https!==null&&r(`div`,{className:`w-full whitespace-normal text-right text-[10px] text-foreground-subtle`,"data-testid":`renew-reason-${t.nodeId}`,children:a}),!t.isHub&&o!==null&&r(`div`,{className:`w-full whitespace-normal text-right text-[10px] text-foreground-subtle`,"data-testid":`mesh-reason-${t.nodeId}`,children:o})]})}function tr(t){return[{mobile:`primary`,key:`node`,header:q.t(`certificates.nodesColumns.node`,`Node`),sortValue:e=>e.isHub?``:e.nodeId.toLowerCase(),render:t=>e(`div`,{className:`flex items-center gap-1.5`,children:[r(`span`,{className:`font-medium text-foreground`,children:t.nodeId}),t.nodeId===`hub`&&r(I,{variant:`info`,className:`text-[10px]`,children:q.t(`common.hubWord`)}),!t.online&&r(I,{variant:`default`,className:`text-[10px]`,children:q.t(`common.offline`)})]})},{mobile:`detail`,key:`https-state`,header:`HTTPS`,notSortableReason:`A state with a reason has no single order.`,render:e=>r(Yn,{row:e})},{mobile:`hidden`,key:`https-expires`,header:q.t(`certificates.nodesColumns.httpsExpires`,`HTTPS expires`),sortValue:e=>qn(e),render:e=>r(Jn,{ms:qn(e),now:t.now})},{mobile:`detail`,key:`identity`,header:q.t(`certificates.nodesColumns.identity`,`Identity`),sortValue:e=>e.mesh?.current?.serial??null,render:e=>r(Xn,{row:e})},{mobile:`hidden`,key:`identity-expires`,header:q.t(`certificates.nodesColumns.identityExpires`,`Identity expires`),sortValue:e=>e.mesh?.current?.notAfter??null,render:e=>r(Jn,{ms:e.mesh?.current?.notAfter??null,now:t.now})},{mobile:`hidden`,key:`presenting`,header:q.t(`certificates.nodesColumns.inUse`,`In use`),notSortableReason:`Offline nodes have no answer to order by.`,render:e=>r(Zn,{row:e})},{mobile:`keep`,key:`actions`,header:q.t(`certificates.nodesColumns.actions`,`Actions`),align:`right`,notSortableReason:`Actions have no order.`,render:e=>r(er,{row:e,o:t})}]}s();function nr(){let{t}=J(),i=T(),o=z.useUtils(),s=xn(6e4),c=z.certificates.listHttpsCertificates.useQuery(),l=z.certificates.getMeshCertificates.useQuery(),[u,d]=a(null),[f,p]=a(null),[m,h]=a(null),g=()=>{h(null),o.certificates.listHttpsCertificates.invalidate(),o.certificates.getMeshCertificates.invalidate()},_=e=>(t,n)=>{h(null),d(`${n.nodeId}: ${e} - ${t.message}`)},v=z.certificates.renewHttpsOnNode.useMutation({onSuccess:(e,n)=>{p({tone:`success`,message:e.restartRequired?t(`certificates.nodesCard.newCertificateIssuedRestartThe`,`{{nodeId}}: new certificate issued. Restart the node to serve it.`,{nodeId:n.nodeId}):t(`certificates.nodesCard.newCertificateIssuedAndServed`,`{{nodeId}}: new certificate issued and served.`,{nodeId:n.nodeId})}),g()},onError:_(`renewal failed`)}),y=z.certificates.renewMeshOnNode.useMutation({onSuccess:e=>{p(It(e)),g()},onError:_(`renewal could not start`)}),b=z.certificates.revokeMeshOnNode.useMutation({onSuccess:e=>{p({tone:`success`,message:`${e.nodeId}: ${e.next}`}),g()},onError:_(`revoke failed`)}),x=v.isPending||y.isPending||b.isPending,S=(e,t)=>{d(null),p(null),h({nodeId:e,action:t})},C=async e=>{await i({title:t(`certificates.nodesCard.renewHttpsOn`,`Renew HTTPS on "{{nodeId}}"?`,{nodeId:e.nodeId}),message:e.isHub?t(`certificates.nodesCard.aNewCertificateIsIssued`,`A new certificate is issued from the local CA. Clients that trust the CA keep working.`):t(`certificates.nodesCard.theNodeMakesANew`,`The node makes a new key, the hub signs it and the node switches over without a restart. It keeps serving what it had if anything fails.`),confirmLabel:t(`certificates.nodesCard.renew`,`Renew`)})&&(S(e.nodeId,`renew-https`),v.mutate({nodeId:e.nodeId}))},w=e=>{S(e.nodeId,`renew-identity`),y.mutate({nodeId:e.nodeId})},E=async e=>{await i({title:t(`certificates.nodesCard.revokeTheIdentityOf`,`Revoke the identity of "{{nodeId}}"?`,{nodeId:e.nodeId}),message:t(`certificates.nodesCard.isDisconnectedAtOnceAnd`,`{{nodeId}} is disconnected at once and can no longer connect. To bring it back it must be paired again from System → Cluster → Agents. It stays in the node list until you forget it on the Cluster page. This cannot be undone.`,{nodeId:e.nodeId}),confirmLabel:t(`certificates.nodesCard.revokeAndDisconnect`,`Revoke and disconnect`),variant:`danger`})&&(S(e.nodeId,`revoke-identity`),b.mutate({nodeId:e.nodeId}))},O=tr({now:s,busy:x,running:m,onRenewHttps:e=>void C(e),onRenewIdentity:w,onRevokeIdentity:e=>void E(e)}),ee=n(()=>Vn(c.data??[],l.data),[c.data,l.data]),k=l.data?.registryAvailable??!0;return r(X,{id:`nodes`,title:t(`certificates.nodesCard.nodes`,`Nodes`),icon:D,description:t(`certificates.nodesCard.eachNodeHoldsTwoCertificates`,`Each node holds two certificates: one it serves over HTTPS, one that proves its identity to the hub. Renewing replaces a certificate without a gap; revoking an identity cuts the node off until it re-joins.`),notice:Y(u,f),onDismissNotice:()=>{d(null),p(null)},children:r(vn,{isPending:c.isPending||l.isPending,error:c.error??l.error,what:`node certificates`,onRetry:()=>{c.refetch(),l.refetch()},children:e(`div`,{className:`space-y-3`,children:[r(Bn,{https:c.data??[],mesh:l.data,now:s}),r(Ce,{columns:O,rows:ee,rowKey:e=>e.nodeId,minWidthPx:960,maxBodyHeight:Le,defaultSort:{columnKey:`node`,dir:`asc`},emptyMessage:k?t(`certificates.nodesCard.noNodesReported`,`No nodes reported.`):t(`certificates.nodesCard.theCertificateRegistryIsNot`,`The certificate registry is not available yet, so nodes cannot be listed.`)})]})})})}function rr({pairOpen:t,onPairClose:n}){return e(`div`,{className:`space-y-4`,"data-testid":`certificates-page`,children:[r(Dn,{pairOpen:t,onPairClose:n}),r(yn,{}),r(Ln,{}),r(nr,{})]})}function ir({userId:t,username:n,onClose:i}){let{t:a}=J(),o=T(),s=z.useUtils(),c=V({userId:t}),l=z.auth.listLoginMethods.useQuery(),u=De({onSuccess:()=>void s.userManagement.listExternalIdentities.invalidate()}),d=new Map((l.data??[]).flatMap(e=>e.kind===`redirect`?[[e.id,e.label]]:[])),f=c.data??[],p=async(e,r)=>{await o({title:a(`users.externalIdentitiesModal.removeSignInLink`,`Remove sign-in link`),message:a(`users.externalIdentitiesModal.willNoLongerBeAble`,`"{{username}}" will no longer be able to sign in with this {{label}} account.`,{username:n,label:r}),confirmLabel:a(`common.remove`,`Remove`),variant:`danger`})&&u.mutate({userId:t,provider:e.provider,subject:e.subject})};return r(L,{open:!0,onOpenChange:e=>!e&&i(),children:e(Qe,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`external-identities-modal`,children:[r(Ke,{children:e(W,{className:`flex items-center gap-2`,children:[r(O,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[a(`users.externalIdentitiesModal.linkedSignInAccounts`,`Linked sign-in accounts`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[a(`users.externalIdentitiesModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),r(He,{className:`space-y-3`,children:c.isLoading?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),a(`common.loading`,`Loading…`)]}):f.length===0?r(`p`,{className:`text-xs text-foreground-subtle`,children:a(`users.externalIdentitiesModal.noLinkedAccountsOnlyThe`,`No linked accounts. Only the user can link one, from their own profile page.`)}):r(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:f.map(t=>{let n=d.get(t.provider),i=n??t.provider;return e(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[e(`div`,{className:`flex-1 min-w-0`,children:[e(`div`,{className:`font-medium text-foreground truncate`,children:[i,n===void 0&&r(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:a(`users.externalIdentitiesModal.providerUnavailable`,`provider unavailable`)})]}),e(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:[t.label??t.subject,` ·`,` `,new Date(t.linkedAt).toLocaleDateString()]})]}),e(j,{variant:`unstyled`,onClick:()=>void p(t,i),disabled:u.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[r(he,{className:`h-3 w-3`}),a(`common.remove`,`Remove`)]})]},`${t.provider}|${t.subject}`)})})}),r(Ze,{children:r(j,{onClick:i,variant:`secondary`,children:a(`common.close`,`Close`)})})]})})}function ar({userId:t,username:n,onClose:i}){let{t:a}=J(),o=c(),s=T(),u=be({userId:t}),d=u.data,f=()=>o.invalidateQueries({queryKey:[[`userManagement`,`getTotpStatus`]]}),p=Ne({onSuccess:()=>{f(),i()}}),h=u.isLoading?`loading`:d?.enabled?`enrolled`:`not_enrolled`;return r(L,{open:!0,onOpenChange:e=>!e&&i(),children:e(Qe,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(Ke,{children:e(W,{className:`flex items-center gap-2`,children:[r(g,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[a(`users.totpModal.twoFactorAuthentication`,`Two-factor authentication`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[a(`users.totpModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),e(He,{className:`space-y-4`,children:[h===`loading`&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),a(`users.totpModal.checkingStatus`,`Checking status…`)]}),h===`not_enrolled`&&e(`div`,{className:`rounded-md border border-border bg-surface-hover/30 px-3 py-2.5 flex items-start gap-2.5 text-xs text-foreground-subtle`,children:[r(ee,{className:`h-4 w-4 mt-0.5 shrink-0`}),e(`div`,{children:[r(`div`,{className:`font-medium text-foreground`,children:a(`users.totpModal.2faNotEnrolled`,`2FA not enrolled`)}),r(`p`,{className:`mt-0.5`,children:a(`users.totpModal.onlyTheUserThemselvesCan`,`Only the user themselves can enable 2FA, from their own profile page.`)})]})]}),h===`enrolled`&&d&&e(l,{children:[e(`div`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2.5 flex items-start gap-2.5`,children:[r(ne,{className:`h-4 w-4 mt-0.5 text-emerald-500 shrink-0`}),e(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[r(`div`,{className:`font-medium`,children:a(`users.totpModal.2faIsActive`,`2FA is active`)}),r(`div`,{className:`text-foreground-subtle`,children:a(`common.enrolledOn`,{when:d.confirmedAt?new Date(d.confirmedAt).toLocaleString():`—`})})]})]}),r(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(`users.totpModal.removingHereClearsTheServer`,`Removing here clears the server-side secret. Use this only when the user has lost access — they'll have to re-enroll from their profile page afterwards.`)}),e(`div`,{className:`flex justify-end gap-2`,children:[r(j,{onClick:i,variant:`secondary`,children:a(`common.close`,`Close`)}),e(j,{variant:`unstyled`,onClick:async()=>{await s({title:a(`users.totpModal.remove2fa`,`Remove 2FA`),message:a(`users.totpModal.removeTwoFactorAuthenticationFor`,`Remove two-factor authentication for "{{username}}"? They'll be able to log in with just their password until they re-enroll from their own profile page.`,{username:n}),confirmLabel:a(`common.remove`,`Remove`),variant:`danger`})&&p.mutate({userId:t})},disabled:p.isPending,className:`rounded bg-danger px-3 py-1.5 text-xs font-medium text-white hover:bg-danger/90 disabled:opacity-50 inline-flex items-center gap-1`,children:[p.isPending?r(k,{className:`h-3 w-3 animate-spin`}):r(m,{className:`h-3 w-3`}),a(`users.totpModal.remove2fa`,`Remove 2FA`)]})]})]})]})]})})}s();function or({userId:t,username:n,onClose:i}){let{t:o}=J(),{user:s,logout:c}=ot(),l=s?.id===t,u=T(),d=z.useUtils(),f=z.auth.listSessions.useQuery({userId:t}),[p,m]=a(null),h=z.auth.revokeSessions.useMutation({onSuccess:(e,t)=>{if(l&&`userId`in t){c();return}d.auth.listSessions.invalidate()},onError:e=>m(`Sign out failed: ${e.message}`)}),g=async e=>{await u({title:o(`users.userSessionsModal.signOutThisSession`,`Sign out this session`),message:o(`users.userSessionsModal.onWillHaveToSign`,`"{{username}}" on {{label}} will have to sign in again.`,{username:n,label:Et(e.client).label}),confirmLabel:o(`users.userSessionsModal.signOut`,`Sign out`),variant:`danger`})&&(m(null),h.mutate({id:e.id}))},_=async()=>{await u({title:o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`),message:l?o(`users.userSessionsModal.everySessionOfYourOwn`,`Every session of your own account ends, this browser included: you will be signed out here too.`):o(`users.userSessionsModal.everySessionOfEndsAt`,`Every session of "{{username}}" ends at once; each device has to sign in again.`,{username:n}),confirmLabel:o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(m(null),h.mutate({userId:t}))},v=h.isPending&&h.variables!==void 0&&`id`in h.variables?h.variables.id:null;return r(L,{open:!0,onOpenChange:e=>!e&&i(),children:e(Qe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`user-sessions-modal`,children:[r(Ke,{children:e(W,{className:`flex items-center gap-2`,children:[r(me,{className:`h-4 w-4 text-primary`}),e(`span`,{children:[o(`users.userSessionsModal.activeSessions`,`Active sessions`),e(`span`,{className:`mt-0.5 block text-[11px] font-normal text-foreground-subtle`,children:[o(`users.userSessionsModal.user`,`User:`),` `,r(`span`,{className:`font-mono`,children:n})]})]})]})}),e(He,{className:`space-y-3`,children:[p!==null&&r(`div`,{className:`text-[11px] text-danger`,children:p}),r(Ht,{sessions:f.data??[],isLoading:f.isLoading,loadError:f.isError?f.error?.message??`Request failed`:null,emptyText:`No active sessions.`,onRevoke:e=>void g(e),revokingId:v})]}),e(Ze,{className:`justify-between`,children:[e(j,{variant:`unstyled`,onClick:()=>void _(),disabled:h.isPending||(f.data??[]).length===0,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[h.isPending&&v===null?r(k,{className:`h-3 w-3 animate-spin`}):r(F,{className:`h-3 w-3`}),o(`users.userSessionsModal.signOutEverywhere`,`Sign out everywhere`)]}),r(j,{onClick:i,variant:`secondary`,children:o(`common.close`,`Close`)})]})]})})}function sr({scopes:t,invalidReason:n}){let{t:i}=J(),a=M(),s=o({queryKey:[`auth`,`previewScope`,t,!1],enabled:n===null,queryFn:()=>a.trpcClient.auth.previewScope.query({scopes:[...t],isAdmin:!1})}),{data:c}=H({projection:`slim`}),l=c?.length??null;if(n!==null)return e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-warning`,"data-testid":`role-preview`,children:[r(C,{className:`h-3 w-3 shrink-0`}),n]});if(s.isLoading)return e(`p`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,"data-testid":`role-preview`,children:[r(k,{className:`h-3 w-3 shrink-0 animate-spin`}),i(`users.rolePreview.resolving`)]});if(s.isError||!s.data)return r(`p`,{className:`text-[11px] text-danger`,"data-testid":`role-preview`,children:i(`users.rolePreview.couldNotResolve`)});let u=s.data.viewableDeviceCount,d=s.data.device.view.all?i(`users.rolePreview.everyDevice`,{count:u}):l===null?i(`users.rolePreview.devicesVisible`,{count:u}):i(`users.rolePreview.devicesVisibleOf`,{count:u,total:l});return e(`p`,{className:`flex items-center gap-1.5 text-[11px] ${u===0?`text-warning`:`text-foreground`}`,"data-testid":`role-preview`,children:[u===0?r(C,{className:`h-3 w-3 shrink-0`}):r(h,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),u===0?i(`users.rolePreview.noDevice`):d]})}function cr(e){let t=N(e.scopes??[]);if(t===null)return{role:e.isAdmin?`admin`:`viewer`,mode:`except`,pickedIds:[],viewer:ce,unconfigured:!e.isAdmin};let n=hr(t);return{role:e.isAdmin?`admin`:`viewer`,mode:n.mode,pickedIds:n.pickedIds,viewer:gr(n.mode,n.pickedIds,t.features),unconfigured:!1}}function lr(e,t){return{...e,role:t}}function ur(e,t){return{...e,mode:t,viewer:gr(t,e.pickedIds,e.viewer.features)}}function dr(e,t){let n=_r(t);return{...e,pickedIds:n,viewer:gr(e.mode,n,e.viewer.features)}}function fr(e,t,n){let r=e.viewer.features.filter(e=>e!==t),i=n?[...r,t]:r;return{...e,viewer:gr(e.mode,e.pickedIds,i)}}function pr(e){return e.role===`viewer`&&e.mode===`only`&&e.pickedIds.length===0?`no-allowed-device`:null}function mr(e){return pr(e)===null?e.role===`admin`?{isAdmin:!0,scopes:[]}:{isAdmin:!1,scopes:[e.viewer]}:null}function hr(e){if(e.allow===`*`)return{mode:`except`,pickedIds:e.block};let t=new Set(e.block);return{mode:`only`,pickedIds:e.allow.filter(e=>!t.has(e))}}function gr(e,t,n){let r=_r(t);return e===`except`?{type:`viewer`,allow:`*`,block:r,features:[...n]}:{type:`viewer`,allow:r,block:[],features:[...n]}}function _r(e){return[...new Set(e)]}s();var vr=`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`;function yr(e,t){return e?`failed`:t===void 0?`pending`:`answered`}function br(e){let t=[];for(let n of e)n.parentDeviceId===null&&t.push({id:n.id,name:n.name,type:String(n.type),...n.location===null?{}:{location:n.location}});return t}function xr({user:t,isSelf:i,onClose:o,onSubmit:s,submitting:c,error:u}){let{t:d}=J(),[f,p]=a(n(()=>cr(t),[t])),m=H({projection:`slim`}),h=m.data,g=yr(m.isError,h),_=n(()=>br(h??[]),[h]),v=n(()=>({state:g,devices:g===`answered`?(h??[]).map(e=>({id:e.id,name:e.name})):void 0}),[g,h]),y=pr(f),b=mr(f),x=y===`no-allowed-device`?d(`users.userAccessModal.pickAllowedDevice`):null,S=e=>{p(lr(f,e))},C=[{value:`except`,label:d(`users.userAccessModal.modeExcept`)},{value:`only`,label:d(`users.userAccessModal.modeOnly`)}];return r(L,{open:!0,onOpenChange:e=>!e&&o(),children:e(Qe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-2xl`,children:[r(Ke,{children:r(W,{children:d(`users.userAccessModal.title`,{name:t.username})})}),e(He,{className:`space-y-4`,children:[f.unconfigured&&f.role===`viewer`&&r(U,{variant:`warning`,title:d(`users.userAccessModal.noAccessYet`),message:d(`users.userAccessModal.noAccessYetDetail`,{name:t.username})}),e(`section`,{className:`space-y-2`,children:[r(`h3`,{className:vr,children:d(`users.userAccessModal.role`)}),e(`div`,{role:`radiogroup`,"aria-label":d(`users.userAccessModal.role`),className:`grid gap-1.5 sm:grid-cols-2`,children:[r(Sr,{name:`admin`,checked:f.role===`admin`,label:d(`users.userAccessModal.admin`),description:d(`users.userAccessModal.adminDescription`),onPick:()=>S(`admin`)}),r(Sr,{name:`viewer`,checked:f.role===`viewer`,disabled:i,label:d(`users.userAccessModal.viewer`),description:d(i?`users.userAccessModal.cannotDemoteSelf`:`users.userAccessModal.viewerDescription`),onPick:()=>S(`viewer`)})]})]}),f.role===`viewer`&&e(l,{children:[e(`section`,{className:`space-y-3`,children:[r(`h3`,{className:vr,children:d(`users.userAccessModal.devices`)}),r(Me,{label:d(`users.userAccessModal.whichDevices`),value:f.mode,options:C,onChange:e=>p(ur(f,e))}),r(qe,{devices:_,listState:g,fleet:v,value:[...f.pickedIds],onChange:e=>p(dr(f,e)),emptyMeansAll:f.mode===`except`,noun:`device`,testId:`viewer-device-picker`}),r(sr,{scopes:b?.scopes??[],invalidReason:x})]}),e(`section`,{className:`space-y-2`,children:[r(`h3`,{className:vr,children:d(`users.userAccessModal.features`)}),r(`div`,{className:`space-y-1`,children:se.map(t=>e(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md p-1.5 hover:bg-surface-hover`,children:[r(ae,{className:`mt-0.5`,checked:f.viewer.features.includes(t.id),onChange:e=>p(fr(f,t.id,e.target.checked))}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`block text-[12px] font-medium text-foreground`,children:d(`users.viewerFeatures.${t.id}.label`,t.label)}),r(`span`,{className:`block text-[10px] text-foreground-subtle`,children:d(`users.viewerFeatures.${t.id}.description`,t.description)})]})]},t.id))})]})]}),u!==null&&r(U,{message:u})]}),e(Ze,{children:[r(j,{variant:`outline`,size:`sm`,onClick:o,children:d(`common.cancel`,`Cancel`)}),r(j,{size:`sm`,onClick:()=>b!==null&&s(b),disabled:c||b===null,children:c?r(k,{className:`h-3 w-3 animate-spin`}):d(`users.userAccessModal.saveAccess`)})]})]})})}function Sr({name:t,checked:n,disabled:i=!1,label:a,description:o,onPick:s}){return e(`label`,{className:`flex items-start gap-2 rounded-lg border p-2.5 transition-colors ${n?`border-primary bg-primary/5`:`border-border hover:bg-surface-hover`} ${i?`cursor-not-allowed opacity-60`:`cursor-pointer`}`,children:[r(Ee,{name:`user-role`,value:t,checked:n,disabled:i,onChange:s,className:`mt-0.5`}),e(`span`,{className:`min-w-0`,children:[r(`span`,{className:`block text-[12px] font-medium text-foreground`,children:a}),r(`span`,{className:`block text-[10px] text-foreground-subtle`,children:o})]})]})}s();var $=8;function Cr(){return{username:``,password:``,isAdmin:!1}}function wr(e){return{id:e.id,username:e.username,password:``,isAdmin:e.isAdmin}}function Tr(e){return e instanceof Error?e.message:q.t(`admin.system.users.genericError`)}function Er(){let{t}=J(),n=c(),{user:o}=ot(),{state:s,openNew:f,openEdit:p,close:m}=ge(),[h,_]=a(null),[v,y]=a(null),[x,C]=a(!1),{data:w,isLoading:E,isError:D,error:ee,refetch:te}=Se(),A=T(),ne=b(),M=()=>n.invalidateQueries({queryKey:[[`userManagement`,`listUsers`]]}),se=xe(),ce=je({onSuccess:M}),N=_e({onSuccess:M}),P=Ie({onSuccess:M}),le=Re(),[F,ue]=a(null),[de,fe]=a(!1),[he,I]=a(null),[L,ve]=a(null),[ye,be]=a(null),[R,z]=a(null),B=w??[],V=s.mode===`edit`?B.find(e=>e.id===s.id)??null:null,H=()=>{_(null),y(null),C(!1),se.reset(),N.reset(),m()};i(()=>{if(s.mode===`closed`){_(null),y(null),C(!1);return}if(s.mode===`new`){_(e=>e!==null&&e.id===void 0?e:Cr());return}if(V===null){E||m();return}_(e=>e?.id===V.id?e:wr(V))},[s,V,E,m]);let we=s.mode===`new`&&h!==null&&h.id===void 0||s.mode===`edit`&&h!==null&&V!==null;async function Ee(e){await A({title:t(`admin.system.users.deleteUser`,`Delete user`),message:t(`admin.system.users.permanentlyDeleteUserThisCannot`,`Permanently delete user "{{username}}"? This cannot be undone — any active sessions will be revoked on next request.`,{username:e.username}),confirmLabel:t(`common.delete`,`Delete`),variant:`danger`,action:()=>ce.mutateAsync({id:e.id})})&&s.mode===`edit`&&s.id===e.id&&H()}async function De(e){let n=await ne({title:t(`admin.system.users.resetPassword`,`Reset password`),message:t(`admin.system.users.setANewPasswordFor`,`Set a new password for "{{username}}".`,{username:e.username}),label:t(`admin.system.users.newPassword`,`New password`),inputType:`password`,placeholder:t(`admin.system.users.atLeast8Characters`,`At least 8 characters`),confirmLabel:t(`admin.system.users.continue`,`Continue`),validate:e=>e.length<$?q.t(`admin.system.users.passwordTooShort`,{min:$}):null});n===null||n.length===0||await A({title:t(`admin.system.users.resetPassword`,`Reset password`),message:t(`admin.system.users.resetThePasswordForThey`,`Reset the password for "{{username}}"? They will need to use the new password on their next login.`,{username:e.username}),confirmLabel:t(`common.reset`,`Reset`)})&&P.mutate({id:e.id,newPassword:n})}function Oe(e){I(null),ue(e)}async function ke(e,t){fe(!0),I(null);try{t.isAdmin!==e.isAdmin&&await N.mutateAsync({id:e.id,isAdmin:t.isAdmin}),await le.mutateAsync({userId:e.id,scopes:[...t.scopes]}),ue(null)}catch(e){I(Tr(e))}finally{fe(!1),M()}}async function Ae(){if(h!==null){y(null);try{if(h.id===void 0){let e=h.username.trim();if(e===``||h.password.length<$)return;await se.mutateAsync({username:e,password:h.password,isAdmin:h.isAdmin})}else await N.mutateAsync({id:h.id,isAdmin:h.isAdmin});M(),H()}catch(e){y(Tr(e))}}}function Me(e){return e?new Date(typeof e==`number`?e:String(e)).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`}):`—`}let Ne=se.isPending||N.isPending,Pe=h!==null&&h.id===void 0&&h.username.trim()!==``&&h.password.length>=$,Fe=h!==null&&h.id!==void 0,Le=Ne||(h?.id===void 0?!Pe:!Fe),ze=e=>ce.isPending&&ce.variables?.id===e.id||N.isPending&&N.variables?.id===e.id||P.isPending&&P.variables?.id===e.id,W=[{mobile:`primary`,key:`username`,header:t(`admin.system.users.username`,`Username`),sortValue:e=>e.username,render:e=>r(`span`,{className:`font-medium text-foreground`,"data-testid":`user-open-${e.id}`,children:e.username})},{mobile:`detail`,key:`scopes`,header:t(`admin.system.users.access`,`Access`),sortValue:e=>Dr(e),render:n=>r(`span`,{onClick:e=>e.stopPropagation(),children:e(j,{size:`sm`,variant:`ghost`,type:`button`,className:`max-sm:h-auto max-sm:whitespace-normal max-sm:px-0 max-sm:text-left`,onClick:()=>Oe(n),disabled:ze(n),title:t(`admin.system.users.configureAccess`,`Configure access`),"data-testid":`user-access-${n.id}`,children:[r(u,{className:`h-3 w-3 shrink-0 text-foreground-subtle`}),r(Or,{user:n})]})})},{mobile:`hidden`,key:`createdAt`,header:t(`admin.system.users.created`,`Created`),nowrap:!0,sortValue:e=>e.createdAt,render:e=>r(`span`,{className:`text-foreground-subtle`,children:Me(e.createdAt)})},{mobile:`keep`,key:`actions`,header:t(`admin.system.users.actions`,`Actions`),align:`right`,nowrap:!0,notSortableReason:`Row actions`,render:n=>{let i=ze(n),a=n.id!==o?.id&&n.totpEnabled;return e(`div`,{className:`flex items-center justify-end gap-1`,onClick:e=>e.stopPropagation(),children:[e(j,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>p(n.id),disabled:i,title:t(`admin.system.users.editUser`,`Edit user`),children:[r(d,{className:`h-3 w-3`}),r(`span`,{className:`max-sm:sr-only`,children:t(`common.edit`,`Edit`)})]}),a&&e(j,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>ve(n),disabled:i,title:t(`admin.system.users.removeTwoFactorAuthentication`,`Remove two-factor authentication`),children:[r(g,{className:`h-3 w-3`}),r(`span`,{className:`max-sm:sr-only`,children:t(`admin.system.users.remove2fa`,`Remove 2FA`)})]}),e(j,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>be(n),disabled:i,title:t(`admin.system.users.linkedSignInAccounts`,`Linked sign-in accounts`),children:[r(O,{className:`h-3 w-3`}),r(`span`,{className:`max-sm:sr-only`,children:t(`admin.system.users.signInLinks`,`Sign-in links`)})]}),e(j,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>z(n),disabled:i,title:t(`admin.system.users.activeSessions`,`Active sessions`),children:[r(me,{className:`h-3 w-3`}),r(`span`,{className:`max-sm:sr-only`,children:t(`admin.system.users.sessions`,`Sessions`)})]}),e(j,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void De(n),disabled:i,title:t(`admin.system.users.resetPassword`,`Reset password`),children:[r(pe,{className:`h-3 w-3`}),r(`span`,{className:`max-sm:sr-only`,children:t(`admin.system.users.resetPassword`,`Reset password`)})]}),e(j,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void Ee(n),disabled:i,title:t(`admin.system.users.deleteUser`,`Delete user`),className:`text-danger hover:bg-danger/10`,children:[i?r(k,{className:`h-3 w-3 animate-spin`}):r(ie,{className:`h-3 w-3`}),r(`span`,{className:`max-sm:sr-only`,children:t(`common.delete`,`Delete`)})]})]})}}];return e(xt,{embedded:!0,icon:S,title:t(`admin.system.users.users`,`Users`),subtitle:t(`admin.system.users.hubAccountsAdminFlagAccess`,`Hub accounts, admin flag, access scopes, sessions and sign-in links.`),actions:e(j,{size:`sm`,type:`button`,onClick:()=>{y(null),f()},children:[r(re,{className:`h-3.5 w-3.5`}),t(`admin.system.users.createUser`,`Create User`)]}),children:[D&&r(U,{title:t(`admin.system.users.couldNotLoadUsers`,`Could not load users`),message:Tr(ee),onRetry:()=>void te()}),E&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),t(`common.loading`,`Loading…`)]}),!E&&!D&&B.length===0&&r(Te,{icon:S,title:t(`admin.system.users.noUsersYet`,`No users yet`),description:t(`admin.system.users.createAUserToGrant`,`Create a user to grant hub access.`)}),!E&&!D&&B.length>0&&r(Ce,{columns:W,rows:B,rowKey:e=>e.id,minWidthPx:560,maxBodyHeight:`max-h-[60vh]`,onRowClick:e=>p(e.id)}),r(Ue,{open:we,onClose:H,title:h?.id===void 0?t(`admin.system.users.createUser`,`Create User`):t(`admin.system.users.edit`,`Edit {{value1}}`,{value1:h.username||`user`}),icon:S,error:v,testId:`user-form-dialog`,footer:r(j,{size:`sm`,type:`button`,disabled:Le,onClick:()=>void Ae(),children:Ne?e(l,{children:[r(k,{className:`h-3.5 w-3.5 animate-spin`}),t(`admin.system.users.saving`,`Saving…`)]}):h?.id===void 0?t(`admin.system.users.create`,`Create`):t(`common.save`,`Save`)}),children:h!==null&&e(`div`,{className:`space-y-3`,children:[r(K,{label:t(`admin.system.users.username`,`Username`),required:h.id===void 0,children:r(oe,{value:h.username,onChange:e=>_({...h,username:e.target.value}),placeholder:`john`,autoFocus:h.id===void 0,disabled:h.id!==void 0,"data-testid":`user-form-username`})}),h.id===void 0&&r(K,{label:t(`admin.system.users.password`,`Password`),required:!0,description:t(`admin.system.users.atLeastCharacters`,`At least {{value1}} characters.`,{value1:String($)}),children:r($e,{value:h.password,onValueChange:e=>_({...h,password:e}),shown:x,onToggleShown:()=>C(e=>!e),placeholder:`••••••••`,"data-testid":`user-form-password`})}),r(K,{label:t(`admin.system.users.admin`,`Admin`),description:t(`admin.system.users.unrestrictedAccessToEveryCapability`,`Unrestricted access to every capability and device.`),children:e(`label`,{className:`inline-flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[r(ae,{checked:h.isAdmin,onChange:e=>_({...h,isAdmin:e.target.checked}),className:`rounded border-border focus:ring-primary`,"data-testid":`user-form-admin`}),r(`span`,{children:t(`admin.system.users.admin`,`Admin`)})]})}),h.id!==void 0&&r(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`admin.system.users.toChangeThePasswordUse`,`To change the password, use Reset password on the user's row. Access scopes are configured from the Access column.`)})]})}),L&&r(ar,{userId:L.id,username:L.username,onClose:()=>ve(null)}),ye&&r(ir,{userId:ye.id,username:ye.username,onClose:()=>be(null)}),R&&r(or,{userId:R.id,username:R.username,onClose:()=>z(null)}),F&&r(xr,{user:F,isSelf:F.id===o?.id,onClose:()=>ue(null),onSubmit:e=>void ke(F,e),submitting:de,error:he})]})}function Dr(e){let t=cr(e);return t.role===`admin`?0:t.unconfigured?2:1}function Or({user:t}){let{t:n}=J(),i=cr(t);if(i.role===`admin`)return r(`span`,{className:`font-medium text-foreground`,children:n(`users.accessSummary.admin`)});if(i.unconfigured)return r(`span`,{className:`font-medium text-warning`,children:n(`admin.system.users.noAccess`,`No access`)});let{allow:a,block:o,features:s}=i.viewer,c=a===`*`?n(`users.accessSummary.allDevices`):n(`users.accessSummary.devices`,{count:a.length});return e(`span`,{className:`text-foreground-subtle`,children:[r(`span`,{className:`font-medium text-foreground`,children:n(`users.accessSummary.viewer`)}),` ·`,` `,c,o.length>0&&e(l,{children:[` · `,n(`users.accessSummary.blocked`,{count:o.length})]}),s.length>0&&e(l,{children:[` · `,n(`users.accessSummary.features`,{count:s.length})]})]})}s();var kr={"api-keys":Q.tokens,"linked-sessions":Q.linkedApps},Ar=`certificates`;function jr(t){return e(j,{size:`sm`,type:`button`,"data-testid":`certificates-pair-device`,onClick:t,children:[r(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),q.t(`systemPage.identity.pairADevice`,`Pair a device`)]})}function Mr(){let{t:e}=J(),[t]=at(),n=mn(),[i,o]=a(!1),s=kr[t.get(`tab`)??``];if(s!==void 0)return r(nt,{to:ft(`access`,{integration:s}),replace:!0});let c=ct(`/system/identity`,{t:e,isAdmin:!0})??{icon:te,title:e(`system.identity`,`Identity & Access`)},l=t.get(`tab`)??`users`,u=t.get(`integration`),d=l===dt.access.tab?pn(u,n.requestCreate):l===`certificates`?jr(()=>o(!0)):void 0;return r(yt,{icon:c.icon,title:c.title,defaultSection:`users`,sectionsLabel:`${c.title} sections`,actions:d,sections:[{id:`users`,label:e(`systemPage.identity.users`,`Users`),content:r(Er,{})},{id:dt.access.tab,label:e(`systemPage.identity.tokensSessions`,`Tokens & sessions`),ownedParams:pt.concat([Nt.token,Nt.scoped,Nt.admin]),content:r(fn,{createRequested:n.createRequested,onCreateConsumed:n.clearCreate})},{id:Ar,label:e(`systemPage.identity.certificates`,`Certificates`),content:r(rr,{pairOpen:i,onPairClose:()=>o(!1)})},{id:dt.authentication.tab,label:e(`systemPage.identity.authentication`,`Authentication`),content:r(hn,{}),ownedParams:pt}]})}export{Mr as IdentityPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,G as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,k as l,o as u,x as d,z as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ar as p,Ja as m,O as h,Tr as ee,V as g,at as te,hr as _,ht as v,li as ne,oi as y,sr as b,wr as re,xn as ie,yt as x,zt as ae}from"./player-overlays-qzCoRsrQ.js";import{Xr as oe}from"./src-CJoX3s-1.js";import{t as se}from"./link-2-off-DmsjRAt7.js";import{$ as ce,$a as S,$i as C,Ci as w,Gr as le,Ir as ue,Jr as de,Pa as fe,Vl as pe,Vo as T,Za as me,_r as E,aa as D,dm as O,ea as k,fm as A,ia as j,mm as M,pm as N,qa as he,qo as P,rt as ge,ta as F,vr as I}from"./src-Cf1Uvi4o.js";import{n as L}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as R}from"./useTranslation-uIxPZ_3N.js";import"./mount-CYNi1aEm.js";import{n as _e,r as ve}from"./broker-oauth-popup-B_GRcwxo.js";import{Bt as z,Ft as ye,Gt as B,Ht as V,Jt as be,Kt as xe,Lt as Se,Mt as Ce,Pt as H,Qt as we,Rt as Te,St as U,Ut as Ee,Vt as W,Wt as De,Xt as Oe,Zt as ke,qt as G,r as K,ut as Ae,zt as je}from"./index-CuIsX0Bx.js";import{t as Me}from"./NodeAddonsSettingsPanel-hnXBekcO.js";c();function q(e,t){return e!==void 0&&e!==``?e:t??void 0}function Ne(e,t,n,r,i){let a=e(`instances.kindIconTip`,`{{kind}} · {{provider}}`,{kind:t,provider:n}),o=new Set((r??[]).map(e=>`${e.field}:${e.instanceId}`)),s=Object.entries(i).filter(([e])=>o.has(e)).map(([,e])=>e);return s.length===0?a:`${a} · ${s.map(t=>e(`instances.sendsVia`,`Sends via {{name}}`,{name:t})).join(` · `)}`}function Pe({addonId:t,label:n,providerName:r,iconUrl:o,links:c}){let{t:l}=R(),u=q(o,U(t)),[d,f]=s({}),p=i((e,t)=>{f(n=>{if(t===null){if(!(e in n))return n;let t={};for(let[r,i]of Object.entries(n))r!==e&&(t[r]=i);return t}return n[e]===t?n:{...n,[e]:t}})},[]),m=Ne(l,n,r,c,d);return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground-muted`,children:[e(O,{children:[a(N,{"aria-label":m,"data-testid":`kind-icon`,children:a(J,{addonId:t,...o===void 0?{}:{iconUrl:o}})}),a(A,{children:m})]}),(c??[]).map(e=>a(Fe,{link:e,ownIcon:u,onFold:p},`${e.field}:${e.instanceId}`)),n]})}function Fe({link:n,ownIcon:r,onFold:i}){let{t:o}=R(),s=W(he({functionCap:n.cap,...n.kind===void 0?{}:{kind:n.kind}}).data??[],n),c=q(s?.iconUrl,U(s?.addonId)),l=s!==void 0&&c===r,u=`${n.field}:${n.instanceId}`,d=l&&s!==void 0?s.name:null;if(t(()=>{i(u,d)},[d,u,i]),s===void 0||l)return null;let f=o(`instances.sendsVia`,`Sends via {{name}}`,{name:s.name});return e(O,{children:[a(N,{"aria-label":f,"data-testid":`linked-instance-badge`,children:a(J,{addonId:s.addonId,...s.iconUrl===void 0?{}:{iconUrl:s.iconUrl},small:!0})}),a(A,{children:f})]})}function J({addonId:e,iconUrl:t,small:n}){let r=U(e),[i,o]=s(new Set),c=[t,r].find(e=>typeof e==`string`&&e!==``&&!i.has(e));return c===void 0?null:a(`img`,{src:te(c),alt:``,className:n===!0?`h-3 w-3 max-w-none shrink-0 rounded-sm`:`h-4 w-4 max-w-none shrink-0 rounded`,onError:()=>o(e=>new Set([...e,c]))})}var Y=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],Ie=`text-[10px]`;function X(){let e=u();return T({onSuccess:()=>{for(let t of Y)e.invalidateQueries({queryKey:t})}})}function Le({addonId:t,displayName:n,message:r}){let{t:i}=R(),o=v(),s=X(),c=i(`integrationHub.addonControls.restartNamed`,`Restart {{name}}`,{name:n});return e(O,{children:[a(N,{children:a(M,{icon:s.isPending?y:_,variant:`ghost`,size:`sm`,"aria-label":c,disabled:s.isPending,onClick:()=>void o({title:i(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:n}),message:r,confirmLabel:i(`integrationHub.addonControls.restart`,`Restart`),variant:`danger`}).then(e=>e?s.mutateAsync({addonId:t}):void 0)})}),a(A,{children:c})]})}function Re({addonId:e,displayName:t,iconOnly:n=!1,description:r}){let{t:i}=R(),o=X(),s=r??i(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`);return n?a(Le,{addonId:e,displayName:t,message:s}):a(ue,{label:i(`integrationHub.addonControls.restart`,`Restart`),icon:_,size:`sm`,title:i(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:s,confirmLabel:i(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:o.isPending,action:()=>o.mutateAsync({addonId:e})})}c();var Z=600,ze=l(null);function Q({id:t,title:r,icon:i,actions:o,framed:s=!1,children:c}){let{t:l}=R(),u=f(ze),p=n(null),m=`integration-section-${t}`;Be(p,u,t);let h=e(d,{children:[u===null?null:a(L,{to:u.sectionHref(t),"aria-label":l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),title:l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:a(ne,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?a(`div`,{ref:p,className:`scroll-mt-4`,children:a(le,{headingId:m,title:r,icon:i,actions:h,children:c})}):e(`section`,{ref:p,"aria-labelledby":m,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[i!==void 0&&a(i,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),a(`h2`,{id:m,className:`${g} min-w-0 flex-1`,children:r}),h]}),c]})}function Be(e,t,n){let r=t?.requestedSection===n,i=t?.integrationId;o(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},Z);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,i,e])}c();var Ve=`max-h-72`,He=[{kind:`logs`,labelKey:`common.logs`,icon:b},{kind:`events`,labelKey:`common.events`,icon:m}];function Ue({addonId:t,switcher:n}){let{t:r}=R(),[i,o]=s(`logs`);return e(Q,{id:K,title:r(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:a(`div`,{className:`flex flex-wrap items-center gap-2`,children:a(`div`,{role:`group`,"aria-label":r(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:He.map(({kind:t,labelKey:n,icon:s})=>e(x,{variant:`unstyled`,type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(s,{className:`h-3 w-3`,"aria-hidden":!0}),r(n)]},t))})}),children:[n!==void 0&&a(`div`,{className:`px-3 pt-2`,children:n}),i===`logs`?a(I,{addonId:t,maxHeight:Ve,showFilters:!1}):a(E,{addonId:t,category:`addon.*`,maxHeight:Ve})]})}function We({addonId:t,title:n=`Settings`,subtitle:r,fieldScope:i,onClose:o}){return a(C,{open:!0,onOpenChange:e=>!e&&o(),children:e(F,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-3xl`,children:[e(j,{children:[a(D,{children:n}),r&&a(`p`,{className:`text-xs text-foreground-subtle`,children:r})]}),a(k,{children:a(Me,{nodeId:null,addonIds:[t],level:`global`,...i===void 0?{}:{fieldScope:i}})})]})})}function Ge({addonId:e,title:t,onClose:n}){return a(We,{addonId:e,title:t,fieldScope:`cluster`,onClose:n})}c();var Ke={md:{tile:`h-10 w-10 rounded-lg`,img:`h-7 w-7 rounded-md p-1`,fallback:`h-5 w-5`},sm:{tile:`h-5 w-5 rounded`,img:`h-5 w-5 rounded p-0.5`,fallback:`h-3.5 w-3.5`}};function qe({addonId:e,fallback:t,tileClassName:n,size:r=`md`}){let[i,o]=s(!1),c=U(e),l=Ke[r];return a(`div`,{className:`${l.tile} flex items-center justify-center shrink-0 ${n}`,children:i||!c?a(t,{className:l.fallback,"aria-hidden":!0}):a(`img`,{src:c,alt:``,className:`${l.img} bg-white ring-1 ring-black/5`,onError:()=>o(!0)})})}var Je={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function Ye(e,t){switch(t){case`ok`:return e(`instances.health.ok`,`Healthy`);case`error`:return e(`instances.health.error`,`Error`);case`off`:return e(`instances.health.off`,`Off`);case`unknown`:return e(`instances.health.unknown`,`Unknown`)}}function Xe({pills:t,selected:n,onSelect:r,fallbackIcon:i,install:o}){let{t:s}=R(),c=t.length>1;return!c&&o===void 0?null:a(`div`,{className:`px-3 pt-2`,children:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c&&a(`div`,{role:`group`,"aria-label":s(`instances.filterByProvider`,`Filter by provider`),className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:t.map(t=>e(x,{variant:`unstyled`,type:`button`,"aria-pressed":n===t.addonId,"data-testid":`instance-pill-${t.addonId}`,onClick:()=>r(n===t.addonId?null:t.addonId),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${n===t.addonId?`border-primary bg-primary/10 text-primary font-medium`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(qe,{addonId:t.addonId,fallback:i,tileClassName:``,size:`sm`}),a(`span`,{className:`truncate`,children:t.name}),a(`span`,{className:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.count}),a(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Je[t.health]}`,"aria-hidden":!0}),a(`span`,{className:`sr-only`,children:Ye(s,t.health)})]},t.addonId))}),o!==void 0&&e(L,{to:oe(o.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[a(re,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),a(`span`,{className:`truncate`,children:o.label})]})]})})}function Ze(e){let t=pe({onSuccess:e.onSuccess,onError:t=>e.onError?.(t.message)});return{mutate:e=>t.mutate({...e}),isPending:t.isPending}}c();function Qe({row:t,pinning:n,onChanged:r}){let{t:i}=R(),o=u(),[c,l]=s(null),d=Ze({onSuccess:()=>{l(null),o.invalidateQueries({queryKey:[H]}),r?.()},onError:l}),f=t.notRunning===void 0?null:i(`providerInstances.addonNotRunning`,`{{addon}} is not running: start it first`,{addon:t.providerName});return e(`span`,{className:`flex flex-col items-start gap-1`,title:f??void 0,children:[a(w,{checked:t.enabled,disabled:d.isPending||f!==null,"aria-label":i(`providerInstances.enable`,`Enable {{name}}`,{name:t.name}),"data-testid":`instance-switch-${t.id}`,onCheckedChange:e=>{l(null),d.mutate({addonId:t.addonId,id:t.id,enabled:e})}}),f!==null&&a(`span`,{className:`text-[11px] text-foreground-subtle`,children:f}),n>0&&a(`span`,{className:`text-[11px] text-foreground-subtle`,children:i(`providerInstances.pinnedBy`,{count:n})}),c!==null&&a(`span`,{className:`text-[11px] text-danger`,role:`alert`,children:i(`providerInstances.switchFailed`,`Could not change {{name}}: {{message}}`,{name:t.name,message:c})})]})}c();var $e=`instance`;function $(t){return e(O,{children:[a(N,{children:a(M,{...t})}),a(A,{children:t[`aria-label`]})]})}function et(e){let t=[e.status?.detail,e.lastCheckedAt===void 0?void 0:new Date(e.lastCheckedAt).toLocaleString()].filter(e=>e!==void 0&&e.length>0);return t.length>0?t.join(` · `):void 0}function tt({row:t}){let{t:n}=R();return t.enabled?e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[a(S,{variant:t.configured?`success`:`default`,children:t.configured?n(`providerInstances.configured`,`Configured`):n(`providerInstances.notConfigured`,`Not configured`)}),t.status!==void 0&&a(S,{variant:t.status.state===`error`?`danger`:t.status.state===`ok`?`success`:`default`,title:et(t),children:G(t.status)})]}):a(`span`,{className:`flex flex-wrap items-center gap-1`,children:a(S,{variant:`default`,children:n(`providerInstances.off`,`Off`)})})}function nt(e,t){return e.kind===`instance`&&e.kindLabel!==void 0&&e.kindLabel.length>0?e.kindLabel:t??``}function rt({row:e,functionCap:t}){let{t:n}=R(),r=u(),i=P({onSuccess:()=>void r.invalidateQueries()});return a(w,{checked:e.isActive,disabled:i.isPending,"aria-label":n(`providerInstances.enable`,`Enable {{name}}`,{name:e.providerName}),onCheckedChange:n=>i.mutate({capName:t,addonId:e.addonId,enabled:n})})}function it({functionCap:t,icon:n,title:o,subtitle:c,emptyTitle:l,emptyDescription:f,addLabel:m,install:g,extraColumns:te,lead:_,rowActions:v,fixedRowActions:b,canDelete:oe,deleteNote:C,onDeleteRefused:w,pageActions:ue,typedId:pe,rowFilter:T,testLabel:E,testHint:D,defaultKindLabel:O}){let{t:k}=R(),A=ae(),j=u(),M=ye(t),N=ce({editKey:$e,newKey:`${$e}-new`}),[P,F]=s(null),[I,L]=s(null),B=he({functionCap:`notification-output`}),V=i(e=>be(B.data??[],e).length,[B.data]),[xe,Ce]=s(null),[U,Ee]=s(null),W=r(()=>Te(M.holders),[M.holders]),G=r(()=>De(M.functionProviders,M.rows,M.displayNames),[M.functionProviders,M.rows,M.displayNames]),K=G.some(e=>e.addonId===U)?U:null,Me=r(()=>{let e=je(M.rows,K);return T===void 0?e:e.filter(T)},[M.rows,K,T]),q=i(e=>M.displayNames.get(e)??e,[M.displayNames]),Ne=i(async e=>{F(e.key),L(null);try{let t=await A.trpcClient.integrationInstances.testInstance.mutate({addonId:e.addonId,id:e.id,values:{}});L({name:e.name,verdict:we(t)})}catch(t){let n=t instanceof Error?t.message:String(t);L({name:e.name,verdict:{status:`inconclusive`,error:n}})}finally{F(null)}},[A]),Fe=i(async(e,t)=>{let n=be(B.data??[],e.id),r=n.length>0?` ${k(`providerInstances.deletePinned`,`These notification targets use it and will stop delivering: {{names}}.`,{names:n.join(`, `)})}`:``,i=C?.(e)??null;await t.destructive(e,{title:k(`providerInstances.deleteTitle`,`Delete {{name}}?`,{name:e.name}),message:`${k(`providerInstances.deleteMessage`,`The record and its stored credentials are removed.`)}${r}${i===null?``:` ${i}`}`,confirmLabel:k(`common.delete`,`Delete`),run:async()=>{try{await A.trpcClient.integrationInstances.deleteInstance.mutate({addonId:e.addonId,id:e.id}),await j.invalidateQueries({queryKey:[H]})}catch(t){if(w!==void 0&&await w(e,t))return;throw t}}})},[C,w,j,A,k,B.data]),J=r(()=>O!==void 0||M.rows.some(e=>e.kind===`instance`&&e.kindLabel!==void 0),[M.rows,O]),Y=i((e,t)=>{e!==void 0&&ve(_e(e,t),()=>{j.invalidateQueries({queryKey:[H]})})},[j]),Ie=r(()=>[{key:`name`,mobile:`primary`,nowrap:!1,header:k(`providerInstances.colName`,`Name`),sortValue:e=>e.name,render:t=>e(`span`,{className:`flex flex-col`,children:[a(`span`,{className:`font-medium ${t.kind===`instance`&&!t.enabled?`text-foreground-muted`:`text-foreground`}`,children:t.name}),t.kind===`fixed`&&t.description.length>0&&a(`span`,{className:`line-clamp-2 text-[11px] text-foreground-subtle`,title:t.description,children:t.description})]})},{key:`provider`,mobile:`hidden`,header:k(`providerInstances.colProvider`,`Provider`),sortValue:e=>e.providerName,render:e=>a(`span`,{className:`text-foreground-muted`,children:e.providerName})},...J?[{key:`kind`,mobile:`hidden`,header:k(`providerInstances.colKind`,`Kind`),sortValue:e=>nt(e,O),render:e=>{let t=nt(e,O);return t===``?a(`span`,{className:`text-foreground-muted`}):a(Pe,{addonId:e.addonId,providerName:e.providerName,label:t,...e.kind===`instance`&&e.kindIconUrl!==void 0?{iconUrl:e.kindIconUrl}:{},...e.kind===`instance`&&e.links!==void 0?{links:e.links}:{}})}}]:[],{key:`state`,mobile:`detail`,header:k(`instances.colStatus`,`Status`),notSortableReason:k(`providerInstances.stateNotSortable`,`A row carries a badge, not a value to order by.`),render:e=>e.kind===`instance`?a(tt,{row:e}):a(S,{variant:e.isActive?`success`:`default`,children:e.isActive?k(`instances.active`,`Active`):k(`providerInstances.off`,`Off`)})},{key:`on`,mobile:`keep`,header:k(`providerInstances.colOn`,`On`),notSortableReason:k(`providerInstances.onNotSortable`,`A switch is not a value to order by.`),render:e=>e.kind===`fixed`?a(rt,{row:e,functionCap:t}):a(Qe,{row:e,pinning:V(e.id)})},...te??[],{key:`actions`,mobile:`keep`,align:`right`,notSortableReason:k(`providerInstances.actionsNotSortable`,`Row actions are not values.`),render:(t,n,r)=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.kind===`instance`&&t.connectPath!==void 0&&a($,{icon:ne,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.connectRow`,`Connect {{name}}`,{name:t.name}),onClick:()=>Y(t.connectPath,t.id)}),t.kind===`instance`&&t.disconnectPath!==void 0&&a($,{icon:se,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.disconnectRow`,`Disconnect {{name}}`,{name:t.name}),onClick:()=>Y(t.disconnectPath,t.id)}),t.kind===`instance`&&t.canTest&&a($,{icon:P===t.key?y:ee,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.testRow`,`Test {{name}}`,{name:t.name}),disabled:P!==null,onClick:()=>void Ne(t)}),t.kind===`instance`&&v?.(t),t.kind===`fixed`&&b?.(t),a($,{icon:p,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.editRow`,`Edit {{name}}`,{name:t.name}),onClick:()=>N.openEdit(z(t.addonId,t.kind===`instance`?t.id:void 0))}),a(Re,{iconOnly:!0,addonId:t.addonId,displayName:t.providerName,description:k(`providerInstances.restartConfirm`,`Restarts the addon on the hub. If it shares a runner group, every addon in that group restarts with it.`)}),t.kind===`instance`&&(oe?.(t)??!0)&&a($,{icon:ie,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.deleteRow`,`Delete {{name}}`,{name:t.name}),onClick:()=>void Fe(t,r)})]})}],[te,N,t,V,v,b,oe,Fe,Y,Ne,J,O,k,P]),X;X=M.state===`error`?a(`div`,{className:`p-3`,children:a(me,{title:k(`providerInstances.loadFailed`,`Could not load the list`),message:M.error??``,onRetry:M.refetch})}):M.state===`pending`?e(`div`,{className:`flex items-center gap-2 p-3 text-xs text-foreground-subtle`,children:[a(y,{className:`h-3 w-3 animate-spin`}),k(`providerInstances.loading`,`Loading…`)]}):M.rows.length===0?a(fe,{icon:n,title:l,description:f}):a(de,{columns:Ie,rows:Me,rowKey:e=>e.key,bordered:!1,onRowActionError:(e,t)=>Oe({title:k(`providerInstances.deleteFailed`,`Could not delete`),message:`${t.name}: ${e}`,severity:`critical`}),emptyMessage:k(`instances.noneForProvider`,`This provider has no instance yet.`)});let Le=M.holders.filter(e=>!W.includes(e)).map(e=>q(e.addonId)),Z=W.length>0?void 0:Le.length>0?k(`instances.addBlocked`,`{{names}}: only one instance is allowed and it already exists.`,{names:Le.join(`, `)}):k(`instances.addNone`,`No provider here can hold instances.`),ze=W.filter(e=>e.addonId===K),Q=Se(ze.length>0?ze:W,q),Be=e(d,{children:[c!==void 0&&a(`p`,{className:`px-3 pt-2 text-xs text-foreground-muted`,children:c}),M.state===`ready`&&Z!==void 0&&a(`p`,{className:`px-3 pt-1 text-[11px] text-foreground-subtle`,children:Z}),M.state===`ready`&&e(d,{children:[e(ge,{children:[ue?.(M.rows.filter(e=>e.kind===`instance`)),e(x,{size:`sm`,variant:`primary`,disabled:Z!==void 0,title:Z,onClick:()=>{let e=Q.length===1?Q[0]:void 0;e===void 0?N.openNew():N.openEdit(z(e.addonId,null,e.kind))},children:[a(re,{className:`h-3.5 w-3.5`}),m]})]}),a(Xe,{pills:G,selected:K,onSelect:Ee,fallbackIcon:n,...g===void 0?{}:{install:g}})]}),X,M.state===`ready`&&M.rows.length>0&&a(at,{rows:M.rows,selected:xe,onSelect:Ce}),I!==null&&e(`div`,{className:`space-y-1 p-3`,children:[a(`p`,{className:`text-[11px] font-medium text-foreground`,children:I.name}),a(ke,{verdict:I.verdict})]}),M.state===`ready`&&N.state.mode===`new`&&a(Ae,{open:!0,onClose:N.close,pickFrom:{title:m,providers:Q.map(e=>({addonId:e.addonId,name:e.label,description:e.kind===void 0?M.descriptions.get(e.addonId)??``:e.providerName,...e.kind===void 0?{}:{kind:e.kind},...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl}})),onPick:(e,t)=>N.openEdit(z(e,null,t))}}),M.state===`ready`&&N.state.mode===`edit`&&a(ot,{refValue:N.state.id,data:M,nameOf:q,onClose:N.close,functionCap:t,onOpen:(e,t)=>N.openEdit(z(e,t)),..._===void 0?{}:{lead:_},...pe===void 0?{}:{typedId:pe},...E===void 0?{}:{testLabel:E},...D===void 0?{}:{testHint:D}},N.state.id)]});return o===void 0?a(`section`,{"aria-label":m,className:h,children:Be}):a(le,{headingId:`provider-instances-${t}`,title:o,icon:n,children:Be})}function at({rows:e,selected:t,onSelect:n}){let{t:i}=R(),o=r(()=>B(e),[e]),s=o[0];if(s===void 0)return null;let c=o.find(e=>e.addonId===t)??s;return a(`div`,{className:`p-3`,children:a(Ue,{addonId:c.addonId,switcher:o.length>1?a(`div`,{role:`group`,"aria-label":i(`providerInstances.activityProvider`,`Activity of`),className:`flex flex-wrap items-center gap-1`,children:o.map(e=>a(x,{variant:`unstyled`,type:`button`,"aria-pressed":e.addonId===c.addonId,onClick:()=>n(e.addonId),className:`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${e.addonId===c.addonId?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.name},e.addonId))}):void 0})})}function ot({refValue:e,data:t,nameOf:n,onClose:r,onOpen:i,lead:o,typedId:s,functionCap:c,testLabel:l,testHint:u}){let d=Ee(e);if(d.kind===`fixed`)return a(Ge,{addonId:d.addonId,title:n(d.addonId),onClose:r});let f=t.holders.find(e=>e.addonId===d.addonId);if(f===void 0)return null;let p=d.kind===`instance`?f.instances.find(e=>e.id===d.id)??null:null;if(d.kind===`instance`&&p===null)return null;let m=d.kind===`create`&&d.kindId!==void 0?xe(f.description,c,d.kindId):null,h=m??f.description,ee=m!==null&&V(f.description)?m.kinds?.[0]?.label:void 0,g=t.rows.find(e=>e.kind===`instance`&&e.addonId===d.addonId&&e.id===p?.id);return a(st,{addonId:d.addonId,...o!==void 0&&g!==void 0?{lead:o(g)}:{},providerName:ee??n(d.addonId),description:h,instance:p,onClose:r,onOpen:i,...s===void 0?{}:{typedId:s},...l===void 0?{}:{testLabel:l},...u===void 0?{}:{testHint:u}})}function st(e){let{onOpen:t,onClose:r,onSaved:i,...o}=e,s=n(null),c=e.instance===null;return a(Ce,{...o,onSaved:e=>{c&&(s.current=e),i?.(e)},onClose:()=>{s.current===null?r():t(e.addonId,s.current)}})}export{qe as n,Ie as r,it as t};
|
|
1
|
+
import{C as e,G as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,k as l,o as u,x as d,z as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ar as p,Ja as m,O as h,Tr as ee,V as g,at as te,hr as _,ht as v,li as ne,oi as y,sr as b,wr as re,xn as ie,yt as x,zt as ae}from"./player-overlays-Cs69NgAR.js";import{Xr as oe}from"./src-BwDSKCnh.js";import{t as se}from"./link-2-off-DmsjRAt7.js";import{$ as ce,$a as S,$i as C,Ci as w,Gr as le,Ir as ue,Jr as de,Pa as fe,Vl as pe,Vo as T,Za as me,_r as E,aa as D,dm as O,ea as k,fm as A,ia as j,mm as M,pm as N,qa as he,qo as P,rt as ge,ta as F,vr as I}from"./src-DWGf7c88.js";import{n as L}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as R}from"./useTranslation-uIxPZ_3N.js";import"./mount-CzwyZiSZ.js";import{n as _e,r as ve}from"./broker-oauth-popup-Bc0452mf.js";import{Bt as z,Ft as ye,Gt as B,Ht as V,Jt as be,Kt as xe,Lt as Se,Mt as Ce,Pt as H,Qt as we,Rt as Te,St as U,Ut as Ee,Vt as W,Wt as De,Xt as Oe,Zt as ke,qt as G,r as K,ut as Ae,zt as je}from"./index-uhNZQRiY.js";import{t as Me}from"./NodeAddonsSettingsPanel-Bgq8ERZo.js";c();function q(e,t){return e!==void 0&&e!==``?e:t??void 0}function Ne(e,t,n,r,i){let a=e(`instances.kindIconTip`,`{{kind}} · {{provider}}`,{kind:t,provider:n}),o=new Set((r??[]).map(e=>`${e.field}:${e.instanceId}`)),s=Object.entries(i).filter(([e])=>o.has(e)).map(([,e])=>e);return s.length===0?a:`${a} · ${s.map(t=>e(`instances.sendsVia`,`Sends via {{name}}`,{name:t})).join(` · `)}`}function Pe({addonId:t,label:n,providerName:r,iconUrl:o,links:c}){let{t:l}=R(),u=q(o,U(t)),[d,f]=s({}),p=i((e,t)=>{f(n=>{if(t===null){if(!(e in n))return n;let t={};for(let[r,i]of Object.entries(n))r!==e&&(t[r]=i);return t}return n[e]===t?n:{...n,[e]:t}})},[]),m=Ne(l,n,r,c,d);return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground-muted`,children:[e(O,{children:[a(N,{"aria-label":m,"data-testid":`kind-icon`,children:a(J,{addonId:t,...o===void 0?{}:{iconUrl:o}})}),a(A,{children:m})]}),(c??[]).map(e=>a(Fe,{link:e,ownIcon:u,onFold:p},`${e.field}:${e.instanceId}`)),n]})}function Fe({link:n,ownIcon:r,onFold:i}){let{t:o}=R(),s=W(he({functionCap:n.cap,...n.kind===void 0?{}:{kind:n.kind}}).data??[],n),c=q(s?.iconUrl,U(s?.addonId)),l=s!==void 0&&c===r,u=`${n.field}:${n.instanceId}`,d=l&&s!==void 0?s.name:null;if(t(()=>{i(u,d)},[d,u,i]),s===void 0||l)return null;let f=o(`instances.sendsVia`,`Sends via {{name}}`,{name:s.name});return e(O,{children:[a(N,{"aria-label":f,"data-testid":`linked-instance-badge`,children:a(J,{addonId:s.addonId,...s.iconUrl===void 0?{}:{iconUrl:s.iconUrl},small:!0})}),a(A,{children:f})]})}function J({addonId:e,iconUrl:t,small:n}){let r=U(e),[i,o]=s(new Set),c=[t,r].find(e=>typeof e==`string`&&e!==``&&!i.has(e));return c===void 0?null:a(`img`,{src:te(c),alt:``,className:n===!0?`h-3 w-3 max-w-none shrink-0 rounded-sm`:`h-4 w-4 max-w-none shrink-0 rounded`,onError:()=>o(e=>new Set([...e,c]))})}var Y=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],Ie=`text-[10px]`;function X(){let e=u();return T({onSuccess:()=>{for(let t of Y)e.invalidateQueries({queryKey:t})}})}function Le({addonId:t,displayName:n,message:r}){let{t:i}=R(),o=v(),s=X(),c=i(`integrationHub.addonControls.restartNamed`,`Restart {{name}}`,{name:n});return e(O,{children:[a(N,{children:a(M,{icon:s.isPending?y:_,variant:`ghost`,size:`sm`,"aria-label":c,disabled:s.isPending,onClick:()=>void o({title:i(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:n}),message:r,confirmLabel:i(`integrationHub.addonControls.restart`,`Restart`),variant:`danger`}).then(e=>e?s.mutateAsync({addonId:t}):void 0)})}),a(A,{children:c})]})}function Re({addonId:e,displayName:t,iconOnly:n=!1,description:r}){let{t:i}=R(),o=X(),s=r??i(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`);return n?a(Le,{addonId:e,displayName:t,message:s}):a(ue,{label:i(`integrationHub.addonControls.restart`,`Restart`),icon:_,size:`sm`,title:i(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:s,confirmLabel:i(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:o.isPending,action:()=>o.mutateAsync({addonId:e})})}c();var Z=600,ze=l(null);function Q({id:t,title:r,icon:i,actions:o,framed:s=!1,children:c}){let{t:l}=R(),u=f(ze),p=n(null),m=`integration-section-${t}`;Be(p,u,t);let h=e(d,{children:[u===null?null:a(L,{to:u.sectionHref(t),"aria-label":l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),title:l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:a(ne,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?a(`div`,{ref:p,className:`scroll-mt-4`,children:a(le,{headingId:m,title:r,icon:i,actions:h,children:c})}):e(`section`,{ref:p,"aria-labelledby":m,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[i!==void 0&&a(i,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),a(`h2`,{id:m,className:`${g} min-w-0 flex-1`,children:r}),h]}),c]})}function Be(e,t,n){let r=t?.requestedSection===n,i=t?.integrationId;o(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},Z);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,i,e])}c();var Ve=`max-h-72`,He=[{kind:`logs`,labelKey:`common.logs`,icon:b},{kind:`events`,labelKey:`common.events`,icon:m}];function Ue({addonId:t,switcher:n}){let{t:r}=R(),[i,o]=s(`logs`);return e(Q,{id:K,title:r(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:a(`div`,{className:`flex flex-wrap items-center gap-2`,children:a(`div`,{role:`group`,"aria-label":r(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:He.map(({kind:t,labelKey:n,icon:s})=>e(x,{variant:`unstyled`,type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(s,{className:`h-3 w-3`,"aria-hidden":!0}),r(n)]},t))})}),children:[n!==void 0&&a(`div`,{className:`px-3 pt-2`,children:n}),i===`logs`?a(I,{addonId:t,maxHeight:Ve,showFilters:!1}):a(E,{addonId:t,category:`addon.*`,maxHeight:Ve})]})}function We({addonId:t,title:n=`Settings`,subtitle:r,fieldScope:i,onClose:o}){return a(C,{open:!0,onOpenChange:e=>!e&&o(),children:e(F,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-3xl`,children:[e(j,{children:[a(D,{children:n}),r&&a(`p`,{className:`text-xs text-foreground-subtle`,children:r})]}),a(k,{children:a(Me,{nodeId:null,addonIds:[t],level:`global`,...i===void 0?{}:{fieldScope:i}})})]})})}function Ge({addonId:e,title:t,onClose:n}){return a(We,{addonId:e,title:t,fieldScope:`cluster`,onClose:n})}c();var Ke={md:{tile:`h-10 w-10 rounded-lg`,img:`h-7 w-7 rounded-md p-1`,fallback:`h-5 w-5`},sm:{tile:`h-5 w-5 rounded`,img:`h-5 w-5 rounded p-0.5`,fallback:`h-3.5 w-3.5`}};function qe({addonId:e,fallback:t,tileClassName:n,size:r=`md`}){let[i,o]=s(!1),c=U(e),l=Ke[r];return a(`div`,{className:`${l.tile} flex items-center justify-center shrink-0 ${n}`,children:i||!c?a(t,{className:l.fallback,"aria-hidden":!0}):a(`img`,{src:c,alt:``,className:`${l.img} bg-white ring-1 ring-black/5`,onError:()=>o(!0)})})}var Je={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function Ye(e,t){switch(t){case`ok`:return e(`instances.health.ok`,`Healthy`);case`error`:return e(`instances.health.error`,`Error`);case`off`:return e(`instances.health.off`,`Off`);case`unknown`:return e(`instances.health.unknown`,`Unknown`)}}function Xe({pills:t,selected:n,onSelect:r,fallbackIcon:i,install:o}){let{t:s}=R(),c=t.length>1;return!c&&o===void 0?null:a(`div`,{className:`px-3 pt-2`,children:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c&&a(`div`,{role:`group`,"aria-label":s(`instances.filterByProvider`,`Filter by provider`),className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:t.map(t=>e(x,{variant:`unstyled`,type:`button`,"aria-pressed":n===t.addonId,"data-testid":`instance-pill-${t.addonId}`,onClick:()=>r(n===t.addonId?null:t.addonId),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${n===t.addonId?`border-primary bg-primary/10 text-primary font-medium`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(qe,{addonId:t.addonId,fallback:i,tileClassName:``,size:`sm`}),a(`span`,{className:`truncate`,children:t.name}),a(`span`,{className:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.count}),a(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Je[t.health]}`,"aria-hidden":!0}),a(`span`,{className:`sr-only`,children:Ye(s,t.health)})]},t.addonId))}),o!==void 0&&e(L,{to:oe(o.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[a(re,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),a(`span`,{className:`truncate`,children:o.label})]})]})})}function Ze(e){let t=pe({onSuccess:e.onSuccess,onError:t=>e.onError?.(t.message)});return{mutate:e=>t.mutate({...e}),isPending:t.isPending}}c();function Qe({row:t,pinning:n,onChanged:r}){let{t:i}=R(),o=u(),[c,l]=s(null),d=Ze({onSuccess:()=>{l(null),o.invalidateQueries({queryKey:[H]}),r?.()},onError:l}),f=t.notRunning===void 0?null:i(`providerInstances.addonNotRunning`,`{{addon}} is not running: start it first`,{addon:t.providerName});return e(`span`,{className:`flex flex-col items-start gap-1`,title:f??void 0,children:[a(w,{checked:t.enabled,disabled:d.isPending||f!==null,"aria-label":i(`providerInstances.enable`,`Enable {{name}}`,{name:t.name}),"data-testid":`instance-switch-${t.id}`,onCheckedChange:e=>{l(null),d.mutate({addonId:t.addonId,id:t.id,enabled:e})}}),f!==null&&a(`span`,{className:`text-[11px] text-foreground-subtle`,children:f}),n>0&&a(`span`,{className:`text-[11px] text-foreground-subtle`,children:i(`providerInstances.pinnedBy`,{count:n})}),c!==null&&a(`span`,{className:`text-[11px] text-danger`,role:`alert`,children:i(`providerInstances.switchFailed`,`Could not change {{name}}: {{message}}`,{name:t.name,message:c})})]})}c();var $e=`instance`;function $(t){return e(O,{children:[a(N,{children:a(M,{...t})}),a(A,{children:t[`aria-label`]})]})}function et(e){let t=[e.status?.detail,e.lastCheckedAt===void 0?void 0:new Date(e.lastCheckedAt).toLocaleString()].filter(e=>e!==void 0&&e.length>0);return t.length>0?t.join(` · `):void 0}function tt({row:t}){let{t:n}=R();return t.enabled?e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[a(S,{variant:t.configured?`success`:`default`,children:t.configured?n(`providerInstances.configured`,`Configured`):n(`providerInstances.notConfigured`,`Not configured`)}),t.status!==void 0&&a(S,{variant:t.status.state===`error`?`danger`:t.status.state===`ok`?`success`:`default`,title:et(t),children:G(t.status)})]}):a(`span`,{className:`flex flex-wrap items-center gap-1`,children:a(S,{variant:`default`,children:n(`providerInstances.off`,`Off`)})})}function nt(e,t){return e.kind===`instance`&&e.kindLabel!==void 0&&e.kindLabel.length>0?e.kindLabel:t??``}function rt({row:e,functionCap:t}){let{t:n}=R(),r=u(),i=P({onSuccess:()=>void r.invalidateQueries()});return a(w,{checked:e.isActive,disabled:i.isPending,"aria-label":n(`providerInstances.enable`,`Enable {{name}}`,{name:e.providerName}),onCheckedChange:n=>i.mutate({capName:t,addonId:e.addonId,enabled:n})})}function it({functionCap:t,icon:n,title:o,subtitle:c,emptyTitle:l,emptyDescription:f,addLabel:m,install:g,extraColumns:te,lead:_,rowActions:v,fixedRowActions:b,canDelete:oe,deleteNote:C,onDeleteRefused:w,pageActions:ue,typedId:pe,rowFilter:T,testLabel:E,testHint:D,defaultKindLabel:O}){let{t:k}=R(),A=ae(),j=u(),M=ye(t),N=ce({editKey:$e,newKey:`${$e}-new`}),[P,F]=s(null),[I,L]=s(null),B=he({functionCap:`notification-output`}),V=i(e=>be(B.data??[],e).length,[B.data]),[xe,Ce]=s(null),[U,Ee]=s(null),W=r(()=>Te(M.holders),[M.holders]),G=r(()=>De(M.functionProviders,M.rows,M.displayNames),[M.functionProviders,M.rows,M.displayNames]),K=G.some(e=>e.addonId===U)?U:null,Me=r(()=>{let e=je(M.rows,K);return T===void 0?e:e.filter(T)},[M.rows,K,T]),q=i(e=>M.displayNames.get(e)??e,[M.displayNames]),Ne=i(async e=>{F(e.key),L(null);try{let t=await A.trpcClient.integrationInstances.testInstance.mutate({addonId:e.addonId,id:e.id,values:{}});L({name:e.name,verdict:we(t)})}catch(t){let n=t instanceof Error?t.message:String(t);L({name:e.name,verdict:{status:`inconclusive`,error:n}})}finally{F(null)}},[A]),Fe=i(async(e,t)=>{let n=be(B.data??[],e.id),r=n.length>0?` ${k(`providerInstances.deletePinned`,`These notification targets use it and will stop delivering: {{names}}.`,{names:n.join(`, `)})}`:``,i=C?.(e)??null;await t.destructive(e,{title:k(`providerInstances.deleteTitle`,`Delete {{name}}?`,{name:e.name}),message:`${k(`providerInstances.deleteMessage`,`The record and its stored credentials are removed.`)}${r}${i===null?``:` ${i}`}`,confirmLabel:k(`common.delete`,`Delete`),run:async()=>{try{await A.trpcClient.integrationInstances.deleteInstance.mutate({addonId:e.addonId,id:e.id}),await j.invalidateQueries({queryKey:[H]})}catch(t){if(w!==void 0&&await w(e,t))return;throw t}}})},[C,w,j,A,k,B.data]),J=r(()=>O!==void 0||M.rows.some(e=>e.kind===`instance`&&e.kindLabel!==void 0),[M.rows,O]),Y=i((e,t)=>{e!==void 0&&ve(_e(e,t),()=>{j.invalidateQueries({queryKey:[H]})})},[j]),Ie=r(()=>[{key:`name`,mobile:`primary`,nowrap:!1,header:k(`providerInstances.colName`,`Name`),sortValue:e=>e.name,render:t=>e(`span`,{className:`flex flex-col`,children:[a(`span`,{className:`font-medium ${t.kind===`instance`&&!t.enabled?`text-foreground-muted`:`text-foreground`}`,children:t.name}),t.kind===`fixed`&&t.description.length>0&&a(`span`,{className:`line-clamp-2 text-[11px] text-foreground-subtle`,title:t.description,children:t.description})]})},{key:`provider`,mobile:`hidden`,header:k(`providerInstances.colProvider`,`Provider`),sortValue:e=>e.providerName,render:e=>a(`span`,{className:`text-foreground-muted`,children:e.providerName})},...J?[{key:`kind`,mobile:`hidden`,header:k(`providerInstances.colKind`,`Kind`),sortValue:e=>nt(e,O),render:e=>{let t=nt(e,O);return t===``?a(`span`,{className:`text-foreground-muted`}):a(Pe,{addonId:e.addonId,providerName:e.providerName,label:t,...e.kind===`instance`&&e.kindIconUrl!==void 0?{iconUrl:e.kindIconUrl}:{},...e.kind===`instance`&&e.links!==void 0?{links:e.links}:{}})}}]:[],{key:`state`,mobile:`detail`,header:k(`instances.colStatus`,`Status`),notSortableReason:k(`providerInstances.stateNotSortable`,`A row carries a badge, not a value to order by.`),render:e=>e.kind===`instance`?a(tt,{row:e}):a(S,{variant:e.isActive?`success`:`default`,children:e.isActive?k(`instances.active`,`Active`):k(`providerInstances.off`,`Off`)})},{key:`on`,mobile:`keep`,header:k(`providerInstances.colOn`,`On`),notSortableReason:k(`providerInstances.onNotSortable`,`A switch is not a value to order by.`),render:e=>e.kind===`fixed`?a(rt,{row:e,functionCap:t}):a(Qe,{row:e,pinning:V(e.id)})},...te??[],{key:`actions`,mobile:`keep`,align:`right`,notSortableReason:k(`providerInstances.actionsNotSortable`,`Row actions are not values.`),render:(t,n,r)=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.kind===`instance`&&t.connectPath!==void 0&&a($,{icon:ne,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.connectRow`,`Connect {{name}}`,{name:t.name}),onClick:()=>Y(t.connectPath,t.id)}),t.kind===`instance`&&t.disconnectPath!==void 0&&a($,{icon:se,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.disconnectRow`,`Disconnect {{name}}`,{name:t.name}),onClick:()=>Y(t.disconnectPath,t.id)}),t.kind===`instance`&&t.canTest&&a($,{icon:P===t.key?y:ee,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.testRow`,`Test {{name}}`,{name:t.name}),disabled:P!==null,onClick:()=>void Ne(t)}),t.kind===`instance`&&v?.(t),t.kind===`fixed`&&b?.(t),a($,{icon:p,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.editRow`,`Edit {{name}}`,{name:t.name}),onClick:()=>N.openEdit(z(t.addonId,t.kind===`instance`?t.id:void 0))}),a(Re,{iconOnly:!0,addonId:t.addonId,displayName:t.providerName,description:k(`providerInstances.restartConfirm`,`Restarts the addon on the hub. If it shares a runner group, every addon in that group restarts with it.`)}),t.kind===`instance`&&(oe?.(t)??!0)&&a($,{icon:ie,variant:`ghost`,size:`sm`,"aria-label":k(`providerInstances.deleteRow`,`Delete {{name}}`,{name:t.name}),onClick:()=>void Fe(t,r)})]})}],[te,N,t,V,v,b,oe,Fe,Y,Ne,J,O,k,P]),X;X=M.state===`error`?a(`div`,{className:`p-3`,children:a(me,{title:k(`providerInstances.loadFailed`,`Could not load the list`),message:M.error??``,onRetry:M.refetch})}):M.state===`pending`?e(`div`,{className:`flex items-center gap-2 p-3 text-xs text-foreground-subtle`,children:[a(y,{className:`h-3 w-3 animate-spin`}),k(`providerInstances.loading`,`Loading…`)]}):M.rows.length===0?a(fe,{icon:n,title:l,description:f}):a(de,{columns:Ie,rows:Me,rowKey:e=>e.key,bordered:!1,onRowActionError:(e,t)=>Oe({title:k(`providerInstances.deleteFailed`,`Could not delete`),message:`${t.name}: ${e}`,severity:`critical`}),emptyMessage:k(`instances.noneForProvider`,`This provider has no instance yet.`)});let Le=M.holders.filter(e=>!W.includes(e)).map(e=>q(e.addonId)),Z=W.length>0?void 0:Le.length>0?k(`instances.addBlocked`,`{{names}}: only one instance is allowed and it already exists.`,{names:Le.join(`, `)}):k(`instances.addNone`,`No provider here can hold instances.`),ze=W.filter(e=>e.addonId===K),Q=Se(ze.length>0?ze:W,q),Be=e(d,{children:[c!==void 0&&a(`p`,{className:`px-3 pt-2 text-xs text-foreground-muted`,children:c}),M.state===`ready`&&Z!==void 0&&a(`p`,{className:`px-3 pt-1 text-[11px] text-foreground-subtle`,children:Z}),M.state===`ready`&&e(d,{children:[e(ge,{children:[ue?.(M.rows.filter(e=>e.kind===`instance`)),e(x,{size:`sm`,variant:`primary`,disabled:Z!==void 0,title:Z,onClick:()=>{let e=Q.length===1?Q[0]:void 0;e===void 0?N.openNew():N.openEdit(z(e.addonId,null,e.kind))},children:[a(re,{className:`h-3.5 w-3.5`}),m]})]}),a(Xe,{pills:G,selected:K,onSelect:Ee,fallbackIcon:n,...g===void 0?{}:{install:g}})]}),X,M.state===`ready`&&M.rows.length>0&&a(at,{rows:M.rows,selected:xe,onSelect:Ce}),I!==null&&e(`div`,{className:`space-y-1 p-3`,children:[a(`p`,{className:`text-[11px] font-medium text-foreground`,children:I.name}),a(ke,{verdict:I.verdict})]}),M.state===`ready`&&N.state.mode===`new`&&a(Ae,{open:!0,onClose:N.close,pickFrom:{title:m,providers:Q.map(e=>({addonId:e.addonId,name:e.label,description:e.kind===void 0?M.descriptions.get(e.addonId)??``:e.providerName,...e.kind===void 0?{}:{kind:e.kind},...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl}})),onPick:(e,t)=>N.openEdit(z(e,null,t))}}),M.state===`ready`&&N.state.mode===`edit`&&a(ot,{refValue:N.state.id,data:M,nameOf:q,onClose:N.close,functionCap:t,onOpen:(e,t)=>N.openEdit(z(e,t)),..._===void 0?{}:{lead:_},...pe===void 0?{}:{typedId:pe},...E===void 0?{}:{testLabel:E},...D===void 0?{}:{testHint:D}},N.state.id)]});return o===void 0?a(`section`,{"aria-label":m,className:h,children:Be}):a(le,{headingId:`provider-instances-${t}`,title:o,icon:n,children:Be})}function at({rows:e,selected:t,onSelect:n}){let{t:i}=R(),o=r(()=>B(e),[e]),s=o[0];if(s===void 0)return null;let c=o.find(e=>e.addonId===t)??s;return a(`div`,{className:`p-3`,children:a(Ue,{addonId:c.addonId,switcher:o.length>1?a(`div`,{role:`group`,"aria-label":i(`providerInstances.activityProvider`,`Activity of`),className:`flex flex-wrap items-center gap-1`,children:o.map(e=>a(x,{variant:`unstyled`,type:`button`,"aria-pressed":e.addonId===c.addonId,onClick:()=>n(e.addonId),className:`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${e.addonId===c.addonId?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.name},e.addonId))}):void 0})})}function ot({refValue:e,data:t,nameOf:n,onClose:r,onOpen:i,lead:o,typedId:s,functionCap:c,testLabel:l,testHint:u}){let d=Ee(e);if(d.kind===`fixed`)return a(Ge,{addonId:d.addonId,title:n(d.addonId),onClose:r});let f=t.holders.find(e=>e.addonId===d.addonId);if(f===void 0)return null;let p=d.kind===`instance`?f.instances.find(e=>e.id===d.id)??null:null;if(d.kind===`instance`&&p===null)return null;let m=d.kind===`create`&&d.kindId!==void 0?xe(f.description,c,d.kindId):null,h=m??f.description,ee=m!==null&&V(f.description)?m.kinds?.[0]?.label:void 0,g=t.rows.find(e=>e.kind===`instance`&&e.addonId===d.addonId&&e.id===p?.id);return a(st,{addonId:d.addonId,...o!==void 0&&g!==void 0?{lead:o(g)}:{},providerName:ee??n(d.addonId),description:h,instance:p,onClose:r,onOpen:i,...s===void 0?{}:{typedId:s},...l===void 0?{}:{testLabel:l},...u===void 0?{}:{testHint:u}})}function st(e){let{onOpen:t,onClose:r,onSaved:i,...o}=e,s=n(null),c=e.instance===null;return a(Ce,{...o,onSaved:e=>{c&&(s.current=e),i?.(e)},onClose:()=>{s.current===null?r():t(e.addonId,s.current)}})}export{qe as n,Ie as r,it as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ea as d,Gi as f,Oa as p,Oo as m,Ri as h,Yt as g,_a as _,_n as v,da as y,fo as b,hr as x,nr as S,oi as C,pr as w,sr as T,vr as E,wr as D,xn as O,xo as k,xt as A,yt as j,zi as M,zt as N}from"./player-overlays-qzCoRsrQ.js";import{Ll as ee,Nc as P}from"./src-CJoX3s-1.js";import{t as F}from"./chevron-down-CBb-F8DT.js";import{t as I}from"./search-x-C5ra3Aft.js";import{$a as L,$i as te,Cc as ne,Ci as R,Ec as z,Ei as B,Fc as V,Gl as re,Io as H,Jl as ie,Ka as ae,Kl as oe,Ll as se,Mc as ce,Om as le,Pi as U,Pr as W,Pt as G,Qr as ue,Rl as de,St as fe,Tm as pe,Tt as me,Uc as K,Vo as he,Wc as q,Wl as ge,Za as J,_i as Y,aa as _e,ac as ve,bc as ye,bs as be,cc as xe,ea as X,fc as Se,gc as Ce,gi as we,hc as Z,hi as Te,i as Ee,ia as De,lc as Oe,oc as ke,ql as Ae,ra as je,sc as Me,ta as Ne,uc as Pe,ul as Fe,vi as Ie,vr as Le,xs as Re,xt as ze,yc as Be,zl as Ve}from"./src-Cf1Uvi4o.js";import{f as He,l as Ue,n as We,p as Ge}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as Q}from"./useTranslation-uIxPZ_3N.js";import{t as Ke}from"./FormBuilder-BjcOGVVa.js";import{$t as qe,Mt as Je,Ot as Ye,St as Xe,ft as Ze,gt as $,ht as Qe,jt as $e,kt as et}from"./index-CuIsX0Bx.js";import{t as tt}from"./useAdminDeviceRemoval-C5EQsX7f.js";import{t as nt}from"./device-integration-icon-B63imyJJ.js";c();function rt(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...rt(n.fields));return t}function it(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...rt(n.fields));return t},[e]),d=u.length>0&&i!==void 0,f=r(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:r(async()=>{if(!i)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await i(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),s(`idle`)},[i,u,t]),clearProbeResult:f}}c();function at(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...at(n.fields));return t}function ot(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function st(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){st(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function ct(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function lt(e,t){let n=K({addonId:e,integrationId:t}),r=n.data?.deviceType??null,i=z({addonId:e,integrationId:t,type:r??P.Camera},{enabled:n.isSuccess&&r!==null});return n.isError?`unavailable`:n.isLoading?`loading`:r===null||i.isError?`unavailable`:i.isLoading||!i.isSuccess?`loading`:((i.data??null)?.sections??[]).some(e=>e.fields.length>0)?`available`:`unavailable`}function ut({integrationId:t,addonId:s,onClose:c}){let{t:d}=Q(),f=l(),[p,m]=o({}),[h,_]=o(!1),[y,b]=o(null),[x,S]=o(ct),w=K({addonId:s,integrationId:t},{enabled:!0}),E=w.data?.deviceType??null,D=z({addonId:s,integrationId:t,type:E??P.Camera},{enabled:w.isSuccess&&E!==null}),O=D.data??null;a(()=>{m(O?st(O.sections.flatMap(e=>e.fields)):{}),S(ct()),_(!1),b(null)},[!0,t,O]);let k=n(()=>({...p,_probeRequestId:x}),[p,x]),A=Z({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),M=Fe(),N=r(async(e,t)=>{_(!0);let n=await M.mutateAsync({addonId:s,type:E??P.Camera,key:e,value:t,formValues:k});return n.status===`ok`&&n.suggestedValues&&m(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))ot(e[i])&&!ot(a)&&(r[i]=a,t=!0);return t?r:e}),n},[M,s,k,E]),{testAllStatus:ee,hasProbeFields:I,probeResults:L,handleTestAll:te,clearProbeResult:ne}=it(O??{sections:[]},p,N);async function R(e){b(null);try{await A.mutateAsync({addonId:s,type:E??P.Camera,config:p,integrationId:t}),e?m(O?st(O.sections.flatMap(e=>e.fields)):{}):c()}catch(e){b(e instanceof Error?e.message:String(e))}}let B=at((O?.sections??[]).flatMap(e=>e.fields)).filter(e=>ot(p[e])),V=B.length===0,re=w.isLoading||E!==null&&D.isLoading,H=w.isError||w.isSuccess&&E===null||D.isError||D.isSuccess&&O===null;return e(u,{children:[i(X,{className:`space-y-3`,children:re?i(`div`,{className:`flex items-center justify-center py-8`,children:i(C,{className:`h-5 w-5 animate-spin text-primary`})}):H?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[i(v,{className:`h-4 w-4 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:d(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(qe,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:s},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Ke,{schema:O,values:p,onChange:m,onTestField:N,probeResults:L,onClearProbe:ne})}),!H&&!re&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(j,{variant:`unstyled`,type:`button`,onClick:()=>_(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(T,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:x.slice(0,14)})]}),i(F,{className:`h-3.5 w-3.5 transition-transform ${h?`rotate-180`:``}`})]}),h&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(Le,{addonId:s,requestId:x,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!H&&!re&&(y||B.length>0)&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(v,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:y||d(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:B.join(`, `)})})]})}),e(je,{className:`justify-between`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(j,{variant:`unstyled`,onClick:c,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:d(`integrations.cancel`)}),!H&&I&&e(j,{variant:`unstyled`,type:`button`,onClick:te,disabled:ee===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[ee===`testing`?i(C,{className:`h-3.5 w-3.5 animate-spin`}):i(g,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(j,{variant:`unstyled`,onClick:()=>R(!0),disabled:H||!V||A.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:d(`integrations.saveAndNew`)}),i(j,{variant:`unstyled`,onClick:()=>R(!1),disabled:H||!V||A.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:A.isPending?d(`integrations.saving`):d(`integrations.save`)})]})]})]})}function dt({deviceId:t,deviceName:n,onNavigate:r}){let{t:a}=Q();return e(`span`,{className:`inline-flex min-w-0 shrink-0 items-center gap-2`,"data-testid":`adopted-mark`,children:[i(L,{variant:`success`,size:`sm`,icon:i(p,{className:`h-3 w-3`}),children:a(`integrations.adoptAlready`,`Adopted`)}),t!==null&&i(We,{to:`/devices/${String(t)}`,onClick:r,className:`truncate text-[11px] text-primary hover:underline`,children:n??a(`integrations.addDeviceModal.openDevice`,`Open device`)})]})}var ft=1500;function pt({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=Q(),s=ke(),c=(Oe({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?ft:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,d=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let f=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&f.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&f.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&f.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let p=f.join(` · `);return e(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[l?i(C,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(v,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(y,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(_,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:p}),l&&i(j,{variant:`unstyled`,onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),c.results.filter(e=>e.outcome===`failed`).slice(0,5).map(t=>e(`p`,{className:`text-[11px] text-destructive`,children:[t.childNativeId,`: `,t.error]},t.childNativeId))]})}function mt(e){let t=e.map(e=>({...e,stableId:e.childNativeId})),n=new Map(e.map(e=>[e.childNativeId,e])),r=(e,t,i)=>e.flatMap(e=>{let a=n.get(e.candidate.childNativeId);return a===void 0?[]:[{candidate:a,depth:t,...i===void 0?{}:{parentName:i}},...r(e.children,t+1,a.name)]});return r(Qe(t),0)}function ht(e){let t=e.metadata?.model,n=e.childNativeId.split(`:`).pop()??``;return[typeof t==`string`?t:``,n].filter(e=>e.length>0).join(` · `)}function gt(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}function _t(e){let t=e.host;return typeof t==`string`&&t.length>0?t.toLowerCase():null}function vt(e){let t=(e??``).toLowerCase().replace(/[^0-9a-f]/g,``);return t.length===12&&(e??``).replace(/[0-9a-fA-F:.-]/g,``).length===0?[`mac:${t}`]:[]}function yt(e){return e===null?[]:[`host:${e}`]}function bt(e){let t=[],n=new Map,r=(e,r)=>{let i=e.map(e=>n.get(e)).find(e=>e!==void 0),a=i??r();i===void 0&&t.push(a);for(let t of e)a.ids.add(t),n.set(t,a);return a},i=(e,t)=>{e.sources.includes(t)||e.sources.push(t)};for(let t of e.adoption){let e=r([t.childNativeId,...vt(t.mac)],()=>({key:t.childNativeId,ids:new Set,name:t.name,address:null,sources:[],hit:null,adoptionId:t.childNativeId,proposalId:null,alreadyAdded:!1,addedName:null,deviceId:null,needsParams:[],parentId:t.parentStableId??null}));i(e,`adoption`),e.adoptionId=t.childNativeId,t.alreadyAdopted===!0&&(e.alreadyAdded=!0),typeof t.adoptedDeviceId==`number`&&(e.deviceId=t.adoptedDeviceId)}let a=(t,n,a)=>{let o=_t(t.prefilledConfig),s=r([t.stableId,...vt(t.sourceInfo?.uniqueId),...yt(o)],()=>({key:t.stableId,ids:new Set,name:t.suggestedName,address:o,sources:[],hit:null,adoptionId:null,proposalId:null,alreadyAdded:!1,addedName:null,deviceId:null,needsParams:[],parentId:null}));i(s,n),(s.hit===null||n===`scan`)&&(s.hit=t),s.name=t.suggestedName,s.address=o??s.address,a!==null&&(s.proposalId=a),s.parentId=t.parentStableId??s.parentId,s.needsParams=t.needsParams??s.needsParams,(t.alreadyOnboarded===!0||t.onboardedDeviceId!==void 0||e.existingStableIds.has(t.stableId))&&(s.alreadyAdded=!0,s.addedName=t.onboardedName??s.addedName,s.deviceId=t.onboardedDeviceId??e.existingDeviceIds?.get(t.stableId)??s.deviceId)};for(let t of e.scan)a(t,`scan`,null);for(let t of e.proposals)a(t.candidate,`proposal`,t.id);for(let n of t){let t=[...n.ids].find(t=>e.existingStableIds.has(t));t!==void 0&&(n.alreadyAdded=!0,n.deviceId=n.deviceId??e.existingDeviceIds?.get(t)??null)}return t.map(e=>{let t=e.parentId===null?void 0:n.get(e.parentId);return{key:e.key,name:e.name,address:e.address,sources:e.sources,hit:e.hit,adoptionId:e.adoptionId,proposalId:e.proposalId,alreadyAdded:e.alreadyAdded,addedName:e.addedName,deviceId:e.deviceId,needsParams:e.needsParams,parentKey:t!==void 0&&t!==e?t.key:null}})}c();function xt(e){return e instanceof Error?e.message:String(e)}function St(e){return e.isSuccess?`answered`:e.isError?`failed`:`pending`}function Ct({addonId:e,integrationId:t,adoption:i,enabled:a=!0}){let s=l(),c=q({addonId:e},{enabled:a}).data??null,[u,d]=o({}),f=Be(),p=V({},{enabled:a}),m=ce({projection:`slim`},{enabled:a}),h=ve(),g=Se(),[_,v]=o(new Set),[y,b]=o(new Set),[x,S]=o(null),[C,w]=o(null),T=n(()=>{if(!a)return[];let t=(p.data?.proposals??[]).filter(t=>t.addonId===e&&!$(t.candidate)).map(e=>({id:e.id,candidate:e.candidate})),n=m.data??[];return bt({adoption:i,scan:(f.data?.candidates??[]).filter(e=>!$(e)),proposals:t,existingStableIds:new Set(n.map(e=>e.stableId)),existingDeviceIds:new Map(n.map(e=>[e.stableId,e.id]))})},[a,i,p.data,f.data,m.data,e]),E=r(()=>{S(null),f.mutate({addonId:e,params:u})},[f,e,u]),D=r(async(e,t)=>{v(t=>new Set(t).add(e)),S(null);try{await t(),b(t=>new Set(t).add(e)),s.invalidateQueries({queryKey:[[`deviceManager`]]}),s.invalidateQueries({queryKey:[[`integrations`]]})}catch(e){S(xt(e))}finally{v(t=>{let n=new Set(t);return n.delete(e),n})}},[s]),O=r(async(n,r)=>{let i=n.hit;if(i!==null){await D(n.key,async()=>{await h.mutateAsync({addonId:e,integrationId:t,candidate:{...i,prefilledConfig:{...i.prefilledConfig,...r}}}),w(null)});return}if(n.adoptionId!==null){let r=n.adoptionId;await D(n.key,async()=>{await g.mutateAsync({addonId:e,integrationId:t,childNativeIds:[r]})})}},[h,g,e,t,D]),k=r(e=>{if(e.needsParams.length>0&&e.hit!==null){S(null),w(e);return}O(e)},[O]);return{rows:T,scanParamsSchema:c,scanParams:u,setScanParams:d,scanning:f.isPending,scanFailed:f.isError,scanAnswered:f.data!==void 0,runScan:E,proposals:a?St(p):`answered`,devices:a?St(m):`answered`,busy:_,added:y,error:x,paramsFor:C,setParamsFor:w,pick:k,addRow:O}}c();var wt=500;function Tt(e){return e instanceof Error?e.message:String(e)}function Et(e,t){let n={};for(let t of e?.sections??[])for(let e of t.fields)`key`in e&&e.key&&`default`in e&&e.default!==void 0&&(n[e.key]=e.default);return{...n,...t}}function Dt({addonId:t,integrationId:a,onClose:o}){let{t:s}=Q(),c=xe({addonId:t,integrationId:a,page:1,pageSize:wt},{retry:!1}),l=Ct({addonId:t,integrationId:a,adoption:n(()=>(c.data?.candidates??[]).map(e=>({childNativeId:e.childNativeId,name:e.name,alreadyAdopted:e.alreadyAdopted,adoptedDeviceId:e.adoptedDeviceId,parentStableId:e.parentStableId})),[c.data])}),{rows:d,paramsFor:f,busy:p,added:m,error:h}=l,g=r(e=>{let t=new Map(d.map(e=>[e.key,e])),n=0,r=e;for(;r?.parentKey!=null&&n<8&&(r=t.get(r.parentKey),r!==void 0);)n+=1;return n},[d]);if(f!==null&&f.hit!==null)return i(Mt,{addonId:t,integrationId:a,row:f,found:f.hit.prefilledConfig,busy:p.has(f.key),error:h,embedded:!1,onBack:()=>l.setParamsFor(null),onSubmit:e=>void l.addRow(f,e)});let _=l.proposals===`answered`&&!l.scanning;return e(u,{children:[e(X,{className:`space-y-3`,children:[i(Ot,{scan:l,listed:d.length}),d.length===0&&_&&i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:l.scanAnswered?s(`integrations.addDeviceModal.nothingFound`,`No devices responded to the scan.`):s(`integrations.addDeviceModal.scanHint`,`Scan the network to find devices to add.`)}),i(`div`,{className:`space-y-1.5`,"data-testid":`network-candidates`,children:d.map(e=>i(jt,{row:e,depth:g(e),busy:p.has(e.key),added:m.has(e.key),devicesKnown:l.devices===`answered`,onPick:l.pick,onNavigate:o},e.key))})]}),i(je,{children:i(j,{variant:`outline`,size:`sm`,onClick:o,children:s(`integrations.close`,`Close`)})})]})}function Ot({scan:t,listed:n}){let{t:r}=Q(),[a,s]=o(!1),c=t.scanning?r(`integrations.addDeviceModal.scanning`,`Scanning the local network…`):n>0?r(`integrations.addDeviceModal.found`,{defaultValue_one:`{{count}} device found`,defaultValue_other:`{{count}} devices found`,count:n}):``;return e(`div`,{className:`shrink-0 space-y-2 pb-3`,"data-testid":`scan-controls`,children:[i(U,{expanded:a,onExpandedChange:s,header:e(u,{children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`text-sm font-medium text-foreground`,children:r(`integrations.addDeviceModal.scanSection`,`Network scan`)}),c!==``&&i(`p`,{className:`truncate text-xs text-foreground-subtle`,children:c})]}),i(`span`,{role:`presentation`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e(j,{variant:`outline`,size:`sm`,onClick:t.runScan,disabled:t.scanning,children:[t.scanning?i(C,{className:`h-3.5 w-3.5 animate-spin`}):i(E,{className:`h-3.5 w-3.5`}),r(`integrations.addDeviceModal.scanNow`,`Scan now`)]})})]}),children:e(`div`,{className:`space-y-3`,children:[i(Ze,{}),t.scanParamsSchema&&i(Ke,{schema:t.scanParamsSchema,values:t.scanParams,onChange:t.setScanParams})]})}),t.scanFailed&&i(kt,{text:r(`integrations.addDeviceModal.scanFailed`,`The scan failed. Try again.`)}),t.proposals===`failed`&&i(kt,{text:r(`integrations.addDeviceModal.proposalsFailed`,`The devices found in the background could not be read. Scan now to look again.`)}),t.devices===`failed`&&i(kt,{text:r(`integrations.addDeviceModal.devicesFailed`,`The hub's device list could not be read, so Add is unavailable. Reopen this window to try again.`)}),t.error!==null&&i(kt,{text:t.error})]})}function kt({text:t}){return e(`div`,{className:`flex items-start gap-2 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2`,children:[i(v,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-danger`}),i(`p`,{className:`text-xs text-danger`,children:t})]})}function At({row:t,busy:n,devicesKnown:r,onPick:a}){let{t:o}=Q();if(t.hit?.selectable===!1)return null;let s=t.needsParams.length>0;return e(j,{size:`sm`,variant:s?`outline`:`primary`,onClick:()=>a(t),disabled:n||!r,children:[n?i(C,{className:`h-3.5 w-3.5 animate-spin`}):s?null:i(f,{className:`h-3.5 w-3.5`}),s?o(`integrations.addDeviceModal.enterDetails`,`Enter details`):o(`common.add`,`Add`)]})}function jt({row:t,depth:n,busy:r,added:a,devicesKnown:o,onPick:s,onNavigate:c}){let l=t.alreadyAdded||a;return e(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2 ${n>0?`ml-4`:``}`,"data-testid":`network-row-${t.key}`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.name}),t.address!==null&&i(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:t.address})]}),l?i(dt,{deviceId:t.deviceId,deviceName:t.addedName,onNavigate:c}):i(At,{row:t,busy:r,devicesKnown:o,onPick:s})]})}function Mt({addonId:t,integrationId:n,row:r,found:a,busy:s,error:c,onBack:l,onSubmit:d,embedded:f}){let{t:p}=Q(),m=K({addonId:t,integrationId:n}),h=m.data?.deviceType??null,g=z({addonId:t,integrationId:n,type:h??P.Camera},{enabled:m.isSuccess&&h!==null}),_=g.data??null,[v,y]=o(null),x=v??Et(_,a),S=m.error??g.error,w=m.isSuccess&&h===null,T=_!==null,E=T?i(Ke,{schema:_,values:x,onChange:y}):S?i(kt,{text:Tt(S)}):w?i(`p`,{className:`text-xs text-foreground-muted`,children:p(`integrations.addDeviceModal.noCreationType`,`This integration cannot create a device from this candidate.`)}):i(C,{className:`mx-auto h-5 w-5 animate-spin text-primary`}),D=e(u,{children:[e(j,{variant:`ghost`,size:`sm`,onClick:l,children:[i(b,{className:`h-3.5 w-3.5`}),p(`integrations.addDeviceModal.back`,`Back to the list`)]}),i(`p`,{className:`text-xs font-medium text-foreground`,children:r.name}),E,c!==null&&i(kt,{text:c})]}),O=e(u,{children:[i(j,{variant:`outline`,size:`sm`,onClick:l,children:p(`integrations.cancel`,`Cancel`)}),e(j,{variant:`primary`,size:`sm`,onClick:()=>d(x),disabled:s||!T,children:[s&&i(C,{className:`h-3.5 w-3.5 animate-spin`}),p(`common.add`,`Add`)]})]});return f?e(`div`,{className:`shrink-0 space-y-3 border-b border-border pb-3`,children:[D,i(`div`,{className:`flex justify-end gap-2`,children:O})]}):e(u,{children:[i(X,{className:`space-y-3`,children:D}),i(je,{children:O})]})}c();var Nt=`devices`;function Pt(e){return{id:Nt,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var Ft=2e4,It=100;function Lt(e,t){if(e.kind===`found`)return{adopted:e.row.alreadyAdded||t.has(e.row.key),deviceId:e.row.deviceId};let{candidate:n,found:r}=e;return{adopted:n.alreadyAdopted||r!==null&&(r.alreadyAdded||t.has(r.key)),deviceId:n.adoptedDeviceId??r?.deviceId??null}}function Rt(e){return e.kind===`candidate`?e.candidate.childNativeId:e.row.key}function zt(e){return e.kind===`candidate`?gt(e.candidate):`${e.row.name} ${e.row.address??``}`.toLowerCase()}function Bt({addonId:s,integrationId:c,onClose:d,withScan:f=!1}){let h=m(),{t:g}=Q(),_=l(),[y,b]=o(new Set),[x,S]=o(new Set),[T,E]=o(new Map),[D,O]=o(null),{data:A}=oe(),M=(A??[]).find(e=>e.addonId===s)?.supportsLocationImport??!1,[N,ee]=o(!0),F=Me({addonId:s,integrationId:c}).data?.filters,I=F&&F.length>0?F:[Pt(g)],[L,te]=o(I.find(e=>e.isDefault)?.id??(I.some(e=>e.id===Nt)?Nt:I[0].id)),ne=L!==Nt,R=Pe(),z=xe({addonId:s,integrationId:c,page:1,pageSize:Ft,filter:L}),B=z.refetch,V=R.mutate,re=r(()=>{V({addonId:s,integrationId:c},{onSettled:()=>{B()}})},[V,s,c,B]),H=t(null);a(()=>{let e=`${s}::${c}`;H.current===e||z.isLoading||(H.current=e,(z.data?.candidates.length??0)===0&&re())},[s,c,z.isLoading,z.data,re]);let ie=R.isPending,ae=R.isError?R.error instanceof Error?R.error.message:String(R.error):null,se=typeof R.data?.lastError==`string`&&R.data.lastError.length>0?R.data.lastError:null,ce=z.data,U=n(()=>ce?.candidates??[],[ce]),W=n(()=>mt(U),[U]),G=Ct({addonId:s,integrationId:c,adoption:n(()=>U.map(e=>({childNativeId:e.childNativeId,name:e.name,alreadyAdopted:e.alreadyAdopted,adoptedDeviceId:e.adoptedDeviceId,parentStableId:e.parentStableId,mac:e.metadata.mac})),[U]),enabled:f}),ue=f&&L===Nt,de=n(()=>{let e=new Map(G.rows.flatMap(e=>e.adoptionId===null?[]:[[e.adoptionId,e]])),t=W.map(t=>({kind:`candidate`,candidate:t.candidate,found:ue?e.get(t.candidate.childNativeId)??null:null})),n=ue?G.rows.filter(e=>e.adoptionId===null).map(e=>({kind:`found`,row:e})):[];return[...t,...n]},[W,G.rows,ue]),fe=n(()=>new Map(W.map(e=>[e.candidate.childNativeId,e.depth])),[W]),me=n(()=>new Map(W.map(e=>[e.candidate.childNativeId,e.parentName])),[W]),K=z.isError?z.error instanceof Error?z.error.message:String(z.error):null,he=Se(),[q,ge]=o(null),J=r(e=>{e.alreadyAdopted||b(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),Y=r(e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_e=r((e,t)=>{E(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),ve=r(e=>{let t={};for(let n of e){let e=T.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[T]),ye=r(async()=>{O(null);let e=[...y];if(e.length!==0)try{let t=ve(e),{jobId:n}=await he.mutateAsync({addonId:s,integrationId:c,filter:L,childNativeIds:e,...t?{perCandidate:t}:{},...M?{importLocations:N}:{}});ge(n),b(new Set),E(new Map)}catch(e){O(e instanceof Error?e.message:String(e))}},[y,ve,he,s,c,L,M,N]),be=t(null),X=r(()=>{q===null||be.current===q||(be.current=q,B(),_.invalidateQueries({queryKey:[[`integrations`]]}),_.invalidateQueries({queryKey:[[`deviceManager`]]}))},[q,B,_]),Ce=r(e=>{te(e),b(new Set),S(new Set),E(new Map),O(null)},[]),we=y.size,Z=q!==null&&we===0&&!he.isPending,Te=de.filter(e=>e.kind===`found`||e.found!==null&&e.found.hit!==null).length,Ee=(ae??K??se)&&U.length===0?``:ue?G.proposals!==`answered`||G.scanning?``:G.scanAnswered?g(`integrations.addDeviceModal.nothingFound`,`No devices responded to the scan.`):g(`integrations.addDeviceModal.scanHint`,`Scan the network to find devices to add.`):g(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`});return G.paramsFor!==null&&G.paramsFor.hit!==null?i(Mt,{addonId:s,integrationId:c,row:G.paramsFor,found:G.paramsFor.hit.prefilledConfig,busy:G.busy.has(G.paramsFor.key),error:G.error,embedded:!1,onBack:()=>G.setParamsFor(null),onSubmit:e=>{G.paramsFor!==null&&G.addRow(G.paramsFor,e)}}):e(u,{children:[f&&i(Ot,{scan:G,listed:ue?Te:0}),M&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(k,{checked:N,onChange:e=>ee(e.target.checked),className:`accent-primary`}),g(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),e(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2 overflow-hidden`,children:[(ae??K??se)&&U.length===0&&i(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(v,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:g(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-danger/90 mt-0.5`,children:ae??K??se})]})]})}),I.length>1&&i(Vt,{filters:I,activeFilter:L,onSelect:Ce}),i(`div`,{className:`flex-1 min-h-0`,children:i(ze,{mode:`generic`,items:de,pageSize:It,getKey:Rt,getSearchText:zt,getFilterType:e=>e.kind===`candidate`?e.candidate.type:e.row.hit?.type??null,filterOptions:pe(h),filterLabel:g(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:z.isLoading||ie&&U.length===0,searchPlaceholder:g(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:Ee,toolbar:e(j,{variant:`unstyled`,type:`button`,onClick:re,disabled:ie,title:g(`integrations.adoptRefreshTitle`,{defaultValue:`Reload this integration's device list (does not scan the network)`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(w,{className:`h-3.5 w-3.5 ${ie?`animate-spin`:``}`}),g(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:g(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-full sm:w-[55%]`,cellClassName:`max-w-0`,cell:e=>{let t=Lt(e,G.added);if(e.kind===`found`)return i(Ut,{row:e.row,adopted:t.adopted,deviceId:t.deviceId,typeLabel:le(e.row.hit?.type??P.Camera,h).label,alignWithChevron:!ne,onNavigate:d});let n=e.candidate;return i(Ht,{candidate:n,depth:fe.get(n.childNativeId)??0,...me.get(n.childNativeId)===void 0?{}:{containerName:me.get(n.childNativeId)},expandable:!ne,expanded:x.has(n.childNativeId),onToggleExpand:()=>Y(n.childNativeId),adopted:t.adopted,deviceId:t.deviceId,onNavigate:d,typeLabel:le(n.type,h).label})}},{key:`type`,header:g(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=le(t.kind===`candidate`?t.candidate.type:t.row.hit?.type??P.Camera,h),r=n.icon;return e(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),n.label]})}},{key:`select`,header:``,headerClassName:`w-10 sm:w-[15%] text-right`,cellClassName:`text-right`,cell:e=>{if(Lt(e,G.added).adopted)return null;let t=e.kind===`found`?e.row:e.found,n=t!==null&&t.hit!==null&&t.needsParams.length>0;if(t!==null&&(e.kind===`found`||n))return i(`div`,{className:`flex items-center justify-end`,children:i(At,{row:t,busy:G.busy.has(t.key),devicesKnown:G.devices===`answered`,onPick:G.pick})});if(e.kind!==`candidate`)return null;let r=e.candidate;return i(`div`,{className:`flex items-center justify-end`,children:i(j,{variant:`unstyled`,onClick:()=>J(r),"aria-label":y.has(r.childNativeId)?g(`integrations.adoptDevicesModal.deselect`,`Deselect`):g(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${y.has(r.childNativeId)?`border-primary bg-primary`:`border-border`}`,children:y.has(r.childNativeId)&&i(p,{className:`h-3 w-3 text-primary-foreground`})})})}}],isExpanded:e=>!ne&&e.kind===`candidate`&&x.has(e.candidate.childNativeId),renderExpanded:ne?void 0:e=>e.kind===`candidate`?i(Wt,{candidate:e.candidate,hiddenChildIds:T.get(e.candidate.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>_e(e.candidate.childNativeId,t)}):null,rowClassName:e=>Lt(e,G.added).adopted?`opacity-60`:e.kind===`candidate`&&y.has(e.candidate.childNativeId)?`bg-primary/5`:``})})]}),D&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(v,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:D})]})}),q!==null&&i(pt,{addonId:s,integrationId:c,jobId:q,onFinished:X}),e(je,{children:[i(j,{variant:`outline`,size:`sm`,onClick:d,children:g(`integrations.cancel`,{defaultValue:`Cancel`})}),e(j,{variant:`primary`,size:`sm`,onClick:Z?d:ye,disabled:!Z&&(we===0||he.isPending),children:[he.isPending&&i(C,{className:`h-3.5 w-3.5 animate-spin`}),Z?g(`integrations.close`,{defaultValue:`Close`}):g(`integrations.addSelected`,{defaultValue:`Add selected`}),!Z&&we>0?` (${we})`:``]})]})]})}function Vt({filters:e,activeFilter:t,onSelect:n}){let{t:r}=Q();return i(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return i(j,{variant:`unstyled`,type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function Ht({candidate:t,depth:n,containerName:r,expandable:a,expanded:o,onToggleExpand:s,adopted:c,deviceId:l,onNavigate:u,typeLabel:f}){let{t:p}=Q(),m=(t.children??[]).length,h=ht(t);return e(`div`,{className:`flex items-center gap-2.5 min-w-0 ${n>0?`pl-5`:``}`,children:[a&&m>0?e(j,{variant:`unstyled`,type:`button`,onClick:s,"aria-label":o?p(`integrations.adoptDevicesModal.collapse`,`Collapse`):p(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":o,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[i(o?F:d,{className:`h-3.5 w-3.5`}),m]}):a?i(`span`,{className:`h-5 w-5 flex-shrink-0`,"aria-hidden":`true`}):null,e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`truncate text-xs font-medium text-foreground`,"data-testid":`candidate-name`,children:t.name}),h.length>0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-subtitle`,children:h}),r!==void 0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-container`,children:p(`integrations.adoptDevicesModal.inContainer`,`in {{name}}`,{name:r})}),i(`div`,{className:`truncate text-[10px] text-foreground-subtle sm:hidden`,children:f})]}),c&&i(dt,{deviceId:l,onNavigate:u})]})}function Ut({row:t,adopted:n,deviceId:r,typeLabel:a,onNavigate:o,alignWithChevron:s}){return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,"data-testid":`network-row-${t.key}`,children:[s&&i(`span`,{className:`h-5 w-5 flex-shrink-0`,"aria-hidden":`true`}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`truncate text-xs font-medium text-foreground`,"data-testid":`candidate-name`,children:t.name}),t.address!==null&&i(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:t.address}),i(`div`,{className:`truncate text-[10px] text-foreground-subtle sm:hidden`,children:a})]}),n&&i(dt,{deviceId:r,deviceName:t.addedName,onNavigate:o})]})}function Wt({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=Q(),o=t.children??[];return o.length===0?null:i(`div`,{className:`space-y-1 py-1`,children:o.map(t=>{let o=n.has(t.childNativeId),s=t.capabilities??[];return e(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${o?`opacity-50`:``}`,children:[i(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:t.name}),s.length>0&&i(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:s.join(`, `)}),i(j,{variant:`unstyled`,onClick:()=>r(t.childNativeId),"aria-label":o?a(`integrations.adoptDevicesModal.showChild`,`Show child`):a(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:o?a(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):a(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:i(o?M:h,{className:`h-3 w-3`})})]},t.childNativeId)})})}c();var Gt=`flex min-h-0 flex-1 flex-col`;function Kt(e){return e===`manual`?`manual`:e===`pairing`?`pairing`:`network`}function qt({reason:e}){let{t}=Q();return i(X,{children:i(J,{message:t(`integrations.addDeviceModal.scanUnavailable`,{defaultValue:`The network scan is unavailable for this integration: {{reason}}`,reason:e})})})}function Jt({addonId:t,integrationId:n,kind:r,canScan:a,scanFailure:s=null,onClose:c,pairing:l}){let{t:d}=Q(),f=lt(t,n),p=r===`device-adoption`&&a===null,m=r===`device-adoption`||a===!0||s!==null,h=f===`available`,[g,_]=o(null),v=g??(l===void 0?m?`network`:`manual`:`pairing`),y=[m,h,l!==void 0].filter(Boolean).length,b=p?i(X,{children:i(C,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):r===`device-adoption`?e(u,{children:[s!==null&&i(qt,{reason:s}),i(Bt,{addonId:t,integrationId:n,onClose:c,withScan:a===!0})]}):s===null?i(Dt,{addonId:t,integrationId:n,onClose:c}):i(qt,{reason:s}),x=i(ut,{integrationId:n,addonId:t,onClose:c});return i(te,{open:!0,onOpenChange:e=>{e||c()},children:e(Ne,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,className:r===`device-adoption`?`md:h-[85vh]`:void 0,children:[i(De,{children:i(_e,{children:d(`integrations.addDevice`,`Add device`)})}),y>1?e(Te,{value:v,onValueChange:e=>_(Kt(e)),className:Gt,children:[e(Y,{className:`shrink-0`,children:[m&&i(Ie,{value:`network`,children:l?.networkLabel??d(`integrations.addDeviceModal.tabNetwork`,`Found on the network`)}),h&&i(Ie,{value:`manual`,children:d(`integrations.addDeviceModal.tabManual`,`Enter parameters`)}),l!==void 0&&i(Ie,{value:`pairing`,children:l.label})]}),m&&i(we,{value:`network`,className:Gt,children:b}),h&&i(we,{value:`manual`,className:Gt,children:x}),l!==void 0&&i(`div`,{role:`tabpanel`,id:`tabpanel-pairing`,hidden:v!==`pairing`,className:`pt-3`,children:l.render({onPaired:()=>_(`network`)})})]}):l!==void 0&&!m&&!h?l.render({onPaired:()=>_(`network`)}):m?b:h?x:f===`loading`?i(X,{children:i(C,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):i(X,{children:i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:d(`integrations.addDeviceModal.nothingToAdd`,`This integration has no way to add a device from here.`)})})]})})}c();var Yt=`matter`,Xt=`matter-broker`,Zt=[`discovering`,`pase`,`commissioning`,`done`];function Qt(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function $t(e,t){return e===`code-expired`||t?.includes(`matter-commission:code-expired`)?{key:`integrations.addMatter.failure.expired`,defaultValue:`The pairing code expired. Share the device again and paste the new code.`}:e===`device-not-found`||t?.includes(`matter-commission:device-not-found`)?{key:`integrations.addMatter.failure.notFound`,defaultValue:`No Matter device with that code was found on the network.`}:e===`wrong-code`||t?.includes(`matter-commission:wrong-code`)?{key:`integrations.addMatter.failure.wrongCode`,defaultValue:`The pairing code was rejected.`}:e===`invalid-code`||t?.includes(`invalid pairing code`)?{key:`integrations.addMatter.failure.invalid`,defaultValue:`Enter an 11-digit or 21-digit manual code, or a code that starts with MT:.`}:{key:`integrations.addMatter.failure.unknown`,defaultValue:t??`Commissioning failed.`}}function en({brokerId:t,onClose:n,onCommissioned:r}){let{t:s}=Q(),c=Ee({kind:Yt}).data?.find(e=>e.id===t)??null,l=c!==null&&!c.usable,d=Re(),[f,p]=o(``),[m,h]=o({phase:`idle`,failure:null,message:null}),g=m.phase===`discovering`||m.phase===`pase`||m.phase===`commissioning`,_=be({addonId:Xt,brokerId:t??``,key:`commission`},{enabled:t!==null&&g,refetchInterval:g?400:!1});a(()=>{g&&Qt(_.data)&&_.data.phase!==`idle`&&h({phase:_.data.phase,failure:typeof _.data.failure==`string`?_.data.failure:null,message:typeof _.data.message==`string`?_.data.message:null})},[g,_.data]);let v=()=>{t!==null&&(h({phase:`discovering`,failure:null,message:null}),d.mutate({addonId:Xt,brokerId:t,target:{action:`commissionNode`},payload:{pairingCode:f.trim()}},{onSuccess:()=>h({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;h({phase:`failed`,failure:t.includes(`matter-commission:`)?t.split(`matter-commission:`)[1]?.split(`:`)[0]??`unknown`:t.includes(`invalid pairing code`)?`invalid-code`:`unknown`,message:t})}}))},y=m.phase===`failed`?$t(m.failure,m.message):null,b=y===null?null:s(y.key,{defaultValue:y.defaultValue}),x=t===null;return e(u,{children:[e(X,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.addMatter.help`,{defaultValue:`Paste the 11-digit pairing code or the MT: QR code.`})}),x&&i(J,{message:s(`integrations.addMatter.noFabric`,{defaultValue:`This integration is not linked to a Matter fabric. Edit it to link one.`})}),c!==null&&l&&i(J,{message:s(`integrations.addMatter.fabricDown`,{defaultValue:`The Matter fabric is not running ({{state}}). It starts again with the Matter addon; try again in a moment.`,state:c.stateLabel??c.state})}),!x&&e(`div`,{className:`space-y-1.5`,children:[i(B,{htmlFor:`matter-pairing-code`,children:s(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(A,{id:`matter-pairing-code`,value:f,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:g||m.phase===`done`,onChange:e=>p(e.target.value)})]}),m.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":s(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:Zt.map(t=>{let n=m.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&g?i(C,{className:`mr-1 inline h-3 w-3 animate-spin`}):null,s(`integrations.addMatter.phase.${t}`,{defaultValue:t===`discovering`?`Discovering`:t===`pase`?`PASE`:t===`commissioning`?`Commissioning`:`Done`})]},t)})}),b!==null&&i(J,{message:b})]}),e(je,{children:[i(j,{variant:`ghost`,size:`sm`,onClick:n,children:s(`common.close`,{defaultValue:`Close`})}),m.phase===`done`?i(j,{size:`sm`,onClick:r,children:s(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(j,{size:`sm`,disabled:g||x||c===null||l||f.trim().length===0,onClick:v,children:g?s(`integrations.addMatter.working`,{defaultValue:`Adding…`}):s(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})}function tn({addonId:t,integrationId:n,name:r,onClose:a,onSaved:o}){let{t:c}=Q(),l=N(),u=s({queryKey:[`integration-instance-describe`,t],queryFn:()=>l.trpcClient.integrationInstances.describe.query({addonId:t})}),d=s({queryKey:[`integration-instance`,t,n],queryFn:()=>l.trpcClient.integrationInstances.getInstance.query({addonId:t,id:n})});if(u.isSuccess&&d.isSuccess&&d.data!==null)return i(Je,{addonId:t,providerName:r,description:u.data,instance:d.data,onClose:a,onSaved:()=>o()});let f=u.isError||d.isError||d.isSuccess&&!d.data;return i(te,{open:!0,onOpenChange:e=>!e&&a(),children:e(Ne,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(De,{children:e(_e,{children:[c(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,r]})}),i(X,{children:f?i(`p`,{className:`text-[11px] text-danger`,children:c(`integrations.loadFailed`,{defaultValue:`Could not load this integration.`})}):e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(C,{className:`h-3 w-3 animate-spin`}),c(`integrations.loading`,{defaultValue:`Loading…`})]})})]})})}c();function nn(){let{addonId:e=``}=He();return i(an,{addonId:e})}function rn(){return e(`div`,{className:`p-4`,children:[i(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),i(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]})}function an({addonId:t}){let{t:c}=Q(),u=l(),d=Ue(),[f,p]=Ge(),m=N(),[h,g]=o(!1),[_,v]=o(!1),[y,w]=o(!1),{data:E}=Ae(void 0),k=n(()=>(E??[]).filter(e=>e.addonId===t),[E,t]),A=$e(f.get(Ye),k)??``,M=r(e=>{p(t=>{let n=new URLSearchParams(t);return n.set(Ye,e),n},{replace:!0})},[p]),P=n(()=>k.map(e=>({value:e.id,label:e.name})),[k]),{data:F,isLoading:L}=re({id:A},{enabled:!!A}),{data:z,isSuccess:B}=oe(),V=n(()=>{let e=F?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[z,F?.addonId,B]),{data:le,isPending:U}=ye({}),{data:pe,isPending:K}=H({capName:`integration-instances`}),q=(pe??[]).some(e=>e.addonId===t),J=de({addonId:t},{retry:!1,enabled:q}),Y=Ve({addonId:t,id:A},{retry:!1,enabled:q&&A!==``}),{canScan:ve,scanFailure:be}=n(()=>{if(U||K||q&&(J.isPending||Y.isPending))return{canScan:null,scanFailure:null};if(!(le?.providers??[]).some(e=>e.addonId===F?.addonId))return{canScan:!1,scanFailure:null};if(!q)return{canScan:!0,scanFailure:null};let e=J.isError?J.error:Y.isError?Y.error:null;if(J.isError||Y.isError){let t=e instanceof Error?e.message:``;return{canScan:!1,scanFailure:t.length>0?t:`unknown error`}}return{canScan:(Y.data?.addDevice??(J.data===void 0?`none`:ee(J.data)))===`scan`,scanFailure:null}},[U,K,q,J.isPending,J.isError,J.error,J.data,Y.isPending,Y.isError,Y.error,Y.data,le,F?.addonId]),xe=V!==null,Se=F?.info?.fixed===!0,we=n(()=>{let e=F?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.brokerKind??null},[z,F?.addonId,B])===`matter`,Z=Y.data?.formValues?.brokerId,Te=typeof Z==`string`&&Z!==``?Z:null,Ee=xe?c(`integrations.addDevice`,`Add device`):c(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),Oe=n(()=>{let e=F?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.mode??null},[z,F?.addonId,B]);a(()=>{f.get(`add`)===`1`&&xe&&(g(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[f,xe,p]);let{data:ke}=s({queryKey:[`integration-instance-form`,F?.addonId,F?.id],enabled:!!F?.addonId&&!!F?.id,queryFn:()=>m.trpcClient.integrationInstances.instanceFormSchema.query({addonId:F?.addonId??``,id:F?.id??``})}),je=ke!=null&&Array.isArray(ke.sections)&&ke.sections.some(e=>e.fields.length>0),{data:Me}=ce({projection:`slim`},{refetchInterval:3e4}),Pe=[[`integrations`,`get`],{input:{id:A},type:`query`}],Fe=ie({onMutate:async e=>{await u.cancelQueries({queryKey:Pe});let t=u.getQueryData(Pe);return t!=null&&u.setQueryData(Pe,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&u.setQueryData(Pe,r.previous)},onSettled:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ie={isPending:Fe.isPending,mutate:e=>Fe.mutate({id:e.id,enabled:e.enabled})},Re={onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]}),d(k.length>1?et(t):`/integrations`)}},Be=se(Re),He=ge(Re),We=F?.processState===`running`,Ke={isPending:Be.isPending||He.isPending,mutateAsync:async e=>{We?await Be.mutateAsync(e):await He.mutateAsync({id:e.id})}},qe=he({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Je=tt(),Xe=Ce({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ze=ne({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),$=n(()=>Me??[],[Me]),Qe=n(()=>G($),[$]),rt=r(e=>Qe.get(e)??null,[Qe]),it=n(()=>fe(E),[E]),at=r(e=>d(`/devices/${String(e)}`),[d]),ot=n(()=>$.filter(e=>{let t=it(e);return t.kind===`resolved`&&t.integration.id===A}),[$,A,it]),st=n(()=>E===void 0?null:me(ot).length,[E,ot])??`…`;if(L||E===void 0)return i(rn,{});let ct=(z??[]).find(e=>e.addonId===t)?.name??F?.name??t;return F?e(`div`,{className:`flex h-full min-h-0 flex-col gap-4 overflow-x-hidden p-4`,children:[i(ue,{items:[{label:c(`integrationDetail.integrations`,`Integrations`),onClick:()=>d(`/integrations`)},{label:ct}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(on,{addonId:F.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:ct}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[st,` `,c(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-nowrap items-center justify-end gap-2`,children:[!Se&&e(j,{variant:`unstyled`,onClick:()=>{g(!0)},disabled:!xe,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:Ee,children:[i(D,{className:`h-3.5 w-3.5`}),Ee]}),i(`div`,{className:`flex flex-col items-end gap-1`,children:e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ie.isPending?`opacity-60`:``} ${F.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:c(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(R,{checked:F.enabled,onCheckedChange:e=>Ie.mutate({id:A,enabled:e}),disabled:Ie.isPending,"aria-label":F.enabled?c(`integrationDetail.disableIntegration`,`Disable integration`):c(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${F.enabled?`text-success`:`text-foreground-subtle`}`,children:F.enabled?c(`integrationDetail.enabled`,`Enabled`):c(`integrationDetail.disabled`,`Disabled`)}),Ie.isPending&&i(C,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]})}),i(W,{moreLabel:c(`integrationDetail.more`,`More`),actions:[{id:`config`,label:c(`integrations.config`),icon:S,hidden:!(Oe!==`standalone`&&(je||V===`device-adoption`)),onClick:()=>v(!0)},{id:`logs`,label:c(`integrations.logs`,{defaultValue:`Logs`}),icon:T,title:c(`integrations.logs`,{defaultValue:`View logs`}),onClick:()=>w(!0)},{id:`restart`,label:c(`integrationDetail.restart`,`Restart`),icon:x,disabled:qe.isPending,confirm:{title:c(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:F.name}),description:c(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:st}),action:()=>qe.mutateAsync({addonId:F.addonId})}},{id:`delete`,label:c(`integrations.delete`,{defaultValue:`Delete`}),icon:O,danger:!0,hidden:Se||!A,disabled:Ke.isPending,confirm:{title:c(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:c(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:F.name,count:st}),confirmLabel:c(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),action:async()=>{A&&await Ke.mutateAsync({addonId:t,id:A})}}}]})]})]}),k.length>1&&i(`div`,{className:`max-w-sm`,children:i(ae,{mode:`single`,singleDisplay:`field`,label:c(`integrationDetail.instances`,`Integration`),options:P,value:A,onChange:M,testId:`integration-instance-picker`,optionTestIdPrefix:`integration-instance`})}),i(`div`,{className:`min-h-0 flex-1`,children:i(ze,{context:`integration-detail`,devices:$,trpc:m.trpcClient,integrationOf:it,forceIntegrationId:A,urlScope:`root`,lsKey:`integration-detail:${F.addonId}`,resolveIntegrationIcon:nt,resolveParent:rt,onNavigate:at,rowOperation:Je.rowOperation,batchActions:{remove:Je.remove,disable:Xe.mutate,enable:Ze.mutate},...Se?{}:{onDeleteDevice:e=>Je.remove({deviceId:e.id})}})}),h&&A&&V!==null&&i(Jt,{addonId:F.addonId,integrationId:A,kind:V,canScan:ve,scanFailure:be,...we?{pairing:{label:c(`integrations.addMatter.tab`,`Pairing code`),networkLabel:c(`integrations.addMatter.tabNetwork`,`Paired nodes`),render:({onPaired:e})=>i(en,{brokerId:Te,onClose:()=>g(!1),onCommissioned:e})}}:{},onClose:()=>g(!1)}),_&&A&&i(tn,{addonId:F.addonId,integrationId:A,name:F.name,onClose:()=>v(!1),onSaved:()=>{u.invalidateQueries()}}),y&&i(te,{open:!0,onOpenChange:e=>!e&&w(!1),children:e(Ne,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(De,{className:`mb-0`,children:e(_e,{className:`flex items-center gap-2 min-w-0`,children:[i(T,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:F.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[F.addonId,A?` · ${A}`:``]})]})}),i(X,{className:`min-h-0 overflow-hidden p-0`,children:i(Le,{addonId:F.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(I,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:c(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:c(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:t})})]}),e(j,{variant:`unstyled`,onClick:()=>d(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[i(b,{className:`h-3 w-3`}),c(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function on({addonId:e}){let t=Xe(e),[n,r]=o(!1);return!t||n?null:i(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>r(!0)})}export{nn as IntegrationDetailPage};
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ea as d,Gi as f,Oa as p,Oo as m,Ri as h,Yt as g,_a as _,_n as v,da as y,fo as b,hr as x,nr as S,oi as C,pr as w,sr as T,vr as E,wr as D,xn as O,xo as k,xt as A,yt as j,zi as M,zt as N}from"./player-overlays-Cs69NgAR.js";import{Ll as ee,Nc as P}from"./src-BwDSKCnh.js";import{t as F}from"./chevron-down-CBb-F8DT.js";import{t as I}from"./search-x-C5ra3Aft.js";import{$a as L,$i as te,Cc as ne,Ci as R,Ec as z,Ei as B,Fc as V,Gl as re,Io as H,Jl as ie,Ka as ae,Kl as oe,Ll as se,Mc as ce,Om as le,Pi as U,Pr as W,Pt as G,Qr as ue,Rl as de,St as fe,Tm as pe,Tt as me,Uc as K,Vo as he,Wc as q,Wl as ge,Za as J,_i as Y,aa as _e,ac as ve,bc as ye,bs as be,cc as xe,ea as X,fc as Se,gc as Ce,gi as we,hc as Z,hi as Te,i as Ee,ia as De,lc as Oe,oc as ke,ql as Ae,ra as je,sc as Me,ta as Ne,uc as Pe,ul as Fe,vi as Ie,vr as Le,xs as Re,xt as ze,yc as Be,zl as Ve}from"./src-DWGf7c88.js";import{f as He,l as Ue,n as We,p as Ge}from"./chunk-4ZMWKKQ3-BCeNTgXs.js";import{t as Q}from"./useTranslation-uIxPZ_3N.js";import{t as Ke}from"./FormBuilder-BB51iHrB.js";import{$t as qe,Mt as Je,Ot as Ye,St as Xe,ft as Ze,gt as $,ht as Qe,jt as $e,kt as et}from"./index-uhNZQRiY.js";import{t as tt}from"./useAdminDeviceRemoval-y6kJG-64.js";import{t as nt}from"./device-integration-icon-DBlkZ4N3.js";c();function rt(e){let t=[];for(let n of e)n.type===`probe`&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...rt(n.fields));return t}function it(e,t,i){let[a,s]=o(`idle`),[c,l]=o({}),u=n(()=>{let t=[];for(let n of e.sections)t.push(...rt(n.fields));return t},[e]),d=u.length>0&&i!==void 0,f=r(e=>{l(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},[]);return{testAllStatus:a,hasProbeFields:d,probeResults:c,handleTestAll:r(async()=>{if(!i)return;let e=u.filter(e=>{let n=t[e];return n!=null&&String(n).trim()!==``});if(e.length===0)return;s(`testing`);let n={};for(let t of e)n[t]={status:`probing`};l(n);let r=await Promise.allSettled(e.map(async e=>{try{return{key:e,result:await i(e,t[e])}}catch(t){return{key:e,result:{status:`error`,error:t instanceof Error?t.message:String(t)}}}})),a={};for(let e of r)if(e.status===`fulfilled`){let{key:t,result:n}=e.value;a[t]={status:n.status===`ok`?`ok`:`error`,result:n}}l(a),s(`idle`)},[i,u,t]),clearProbeResult:f}}c();function at(e){let t=[];for(let n of e)`required`in n&&n.required===!0&&`key`in n&&n.key&&t.push(n.key),n.type===`group`&&`fields`in n&&t.push(...at(n.fields));return t}function ot(e){return e==null?!0:typeof e==`string`?e.trim()===``:!1}function st(e,t={}){for(let n of e){if(n.type===`group`&&`fields`in n){st(n.fields,t);continue}`key`in n&&n.key&&`default`in n&&n.default!==void 0&&(t[n.key]=n.default)}return t}function ct(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?`probe-${crypto.randomUUID()}`:`probe-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function lt(e,t){let n=K({addonId:e,integrationId:t}),r=n.data?.deviceType??null,i=z({addonId:e,integrationId:t,type:r??P.Camera},{enabled:n.isSuccess&&r!==null});return n.isError?`unavailable`:n.isLoading?`loading`:r===null||i.isError?`unavailable`:i.isLoading||!i.isSuccess?`loading`:((i.data??null)?.sections??[]).some(e=>e.fields.length>0)?`available`:`unavailable`}function ut({integrationId:t,addonId:s,onClose:c}){let{t:d}=Q(),f=l(),[p,m]=o({}),[h,_]=o(!1),[y,b]=o(null),[x,S]=o(ct),w=K({addonId:s,integrationId:t},{enabled:!0}),E=w.data?.deviceType??null,D=z({addonId:s,integrationId:t,type:E??P.Camera},{enabled:w.isSuccess&&E!==null}),O=D.data??null;a(()=>{m(O?st(O.sections.flatMap(e=>e.fields)):{}),S(ct()),_(!1),b(null)},[!0,t,O]);let k=n(()=>({...p,_probeRequestId:x}),[p,x]),A=Z({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),M=Fe(),N=r(async(e,t)=>{_(!0);let n=await M.mutateAsync({addonId:s,type:E??P.Camera,key:e,value:t,formValues:k});return n.status===`ok`&&n.suggestedValues&&m(e=>{let t=!1,r={...e};for(let[i,a]of Object.entries(n.suggestedValues??{}))ot(e[i])&&!ot(a)&&(r[i]=a,t=!0);return t?r:e}),n},[M,s,k,E]),{testAllStatus:ee,hasProbeFields:I,probeResults:L,handleTestAll:te,clearProbeResult:ne}=it(O??{sections:[]},p,N);async function R(e){b(null);try{await A.mutateAsync({addonId:s,type:E??P.Camera,config:p,integrationId:t}),e?m(O?st(O.sections.flatMap(e=>e.fields)):{}):c()}catch(e){b(e instanceof Error?e.message:String(e))}}let B=at((O?.sections??[]).flatMap(e=>e.fields)).filter(e=>ot(p[e])),V=B.length===0,re=w.isLoading||E!==null&&D.isLoading,H=w.isError||w.isSuccess&&E===null||D.isError||D.isSuccess&&O===null;return e(u,{children:[i(X,{className:`space-y-3`,children:re?i(`div`,{className:`flex items-center justify-center py-8`,children:i(C,{className:`h-5 w-5 animate-spin text-primary`})}):H?e(`div`,{className:`flex items-start gap-3 rounded-lg border border-danger/40 bg-danger/10 px-4 py-3`,children:[i(v,{className:`h-4 w-4 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`space-y-1`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:d(`integrations.addDeviceDialog.providerUnavailable`,`Provider unavailable`)}),i(`p`,{className:`text-xs text-foreground-subtle`,children:i(qe,{i18nKey:`integrations.addDeviceDialog.notReady`,values:{addonId:s},components:{mono:i(`span`,{className:`font-mono`})}})})]})]}):i(Ke,{schema:O,values:p,onChange:m,onTestField:N,probeResults:L,onClearProbe:ne})}),!H&&!re&&e(`div`,{className:`border-t border-border bg-surface/50 shrink-0`,children:[e(j,{variant:`unstyled`,type:`button`,onClick:()=>_(e=>!e),className:`flex w-full items-center justify-between px-3 py-2 text-[11px] text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[e(`span`,{className:`flex items-center gap-2`,children:[i(T,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testLogs`,`Test logs`),i(`span`,{className:`font-mono text-[9px] opacity-60`,children:x.slice(0,14)})]}),i(F,{className:`h-3.5 w-3.5 transition-transform ${h?`rotate-180`:``}`})]}),h&&i(`div`,{className:`border-t border-border max-h-64 overflow-hidden`,children:i(Le,{addonId:s,requestId:x,limit:50,maxHeight:`max-h-64`,showFilters:!1,showScope:!1,className:`border-0 rounded-none`})})]}),!H&&!re&&(y||B.length>0)&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(v,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:y||d(`integrations.addDeviceDialog.required`,`Required: {{value1}}`,{value1:B.join(`, `)})})]})}),e(je,{className:`justify-between`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(j,{variant:`unstyled`,onClick:c,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:d(`integrations.cancel`)}),!H&&I&&e(j,{variant:`unstyled`,type:`button`,onClick:te,disabled:ee===`testing`,className:`inline-flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[ee===`testing`?i(C,{className:`h-3.5 w-3.5 animate-spin`}):i(g,{className:`h-3.5 w-3.5`}),d(`integrations.addDeviceDialog.testAll`,`Test All`)]})]}),e(`div`,{className:`flex items-center gap-2`,children:[i(j,{variant:`unstyled`,onClick:()=>R(!0),disabled:H||!V||A.isPending,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:d(`integrations.saveAndNew`)}),i(j,{variant:`unstyled`,onClick:()=>R(!1),disabled:H||!V||A.isPending,className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:A.isPending?d(`integrations.saving`):d(`integrations.save`)})]})]})]})}function dt({deviceId:t,deviceName:n,onNavigate:r}){let{t:a}=Q();return e(`span`,{className:`inline-flex min-w-0 shrink-0 items-center gap-2`,"data-testid":`adopted-mark`,children:[i(L,{variant:`success`,size:`sm`,icon:i(p,{className:`h-3 w-3`}),children:a(`integrations.adoptAlready`,`Adopted`)}),t!==null&&i(We,{to:`/devices/${String(t)}`,onClick:r,className:`truncate text-[11px] text-primary hover:underline`,children:n??a(`integrations.addDeviceModal.openDevice`,`Open device`)})]})}var ft=1500;function pt({addonId:t,integrationId:n,jobId:r,onFinished:a}){let{t:o}=Q(),s=ke(),c=(Oe({addonId:t,integrationId:n},{refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`running`)?ft:!1}).data??[]).find(e=>e.jobId===r);if(!c)return null;let l=c.state===`running`,u=c.processed,d=c.total>0?Math.round(u/c.total*100):0;!l&&c.finishedAt!==null&&a();let f=[`${u}/${c.total} ${o(`integrations.adoptJobProcessed`,{defaultValue:`processed`})}`];c.adopted>0&&f.push(`${c.adopted} ${o(`integrations.adoptJobAdded`,{defaultValue:`added`})}`),c.alreadyAdopted>0&&f.push(`${c.alreadyAdopted} ${o(`integrations.adoptJobSkipped`,{defaultValue:`already there`})}`),c.failed>0&&f.push(`${c.failed} ${o(`integrations.adoptJobFailed`,{defaultValue:`failed`})}`);let p=f.join(` · `);return e(`div`,{className:`border-t border-border px-5 py-3 shrink-0 space-y-2`,children:[e(`div`,{className:`flex items-center gap-2`,children:[l?i(C,{className:`h-3.5 w-3.5 animate-spin text-primary shrink-0`}):c.failed>0?i(v,{className:`h-3.5 w-3.5 text-destructive shrink-0`}):c.state===`cancelled`?i(y,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}):i(_,{className:`h-3.5 w-3.5 text-primary shrink-0`}),i(`p`,{className:`text-[11px] text-foreground`,children:p}),l&&i(j,{variant:`unstyled`,onClick:()=>s.mutate({jobId:r}),className:`ml-auto rounded-lg border border-border px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:o(`integrations.adoptJobCancel`,{defaultValue:`Stop`})})]}),i(`div`,{className:`h-1 w-full rounded-full bg-border overflow-hidden`,children:i(`div`,{className:`h-full bg-primary transition-all`,style:{width:`${d}%`},role:`progressbar`,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100})}),c.results.filter(e=>e.outcome===`failed`).slice(0,5).map(t=>e(`p`,{className:`text-[11px] text-destructive`,children:[t.childNativeId,`: `,t.error]},t.childNativeId))]})}function mt(e){let t=e.map(e=>({...e,stableId:e.childNativeId})),n=new Map(e.map(e=>[e.childNativeId,e])),r=(e,t,i)=>e.flatMap(e=>{let a=n.get(e.candidate.childNativeId);return a===void 0?[]:[{candidate:a,depth:t,...i===void 0?{}:{parentName:i}},...r(e.children,t+1,a.name)]});return r(Qe(t),0)}function ht(e){let t=e.metadata?.model,n=e.childNativeId.split(`:`).pop()??``;return[typeof t==`string`?t:``,n].filter(e=>e.length>0).join(` · `)}function gt(e){let t=e.metadata;return[e.name,e.childNativeId,t.model,t.manufacturer,t.integration,t.externalLocation].filter(e=>typeof e==`string`&&e.length>0).join(` `)}function _t(e){let t=e.host;return typeof t==`string`&&t.length>0?t.toLowerCase():null}function vt(e){let t=(e??``).toLowerCase().replace(/[^0-9a-f]/g,``);return t.length===12&&(e??``).replace(/[0-9a-fA-F:.-]/g,``).length===0?[`mac:${t}`]:[]}function yt(e){return e===null?[]:[`host:${e}`]}function bt(e){let t=[],n=new Map,r=(e,r)=>{let i=e.map(e=>n.get(e)).find(e=>e!==void 0),a=i??r();i===void 0&&t.push(a);for(let t of e)a.ids.add(t),n.set(t,a);return a},i=(e,t)=>{e.sources.includes(t)||e.sources.push(t)};for(let t of e.adoption){let e=r([t.childNativeId,...vt(t.mac)],()=>({key:t.childNativeId,ids:new Set,name:t.name,address:null,sources:[],hit:null,adoptionId:t.childNativeId,proposalId:null,alreadyAdded:!1,addedName:null,deviceId:null,needsParams:[],parentId:t.parentStableId??null}));i(e,`adoption`),e.adoptionId=t.childNativeId,t.alreadyAdopted===!0&&(e.alreadyAdded=!0),typeof t.adoptedDeviceId==`number`&&(e.deviceId=t.adoptedDeviceId)}let a=(t,n,a)=>{let o=_t(t.prefilledConfig),s=r([t.stableId,...vt(t.sourceInfo?.uniqueId),...yt(o)],()=>({key:t.stableId,ids:new Set,name:t.suggestedName,address:o,sources:[],hit:null,adoptionId:null,proposalId:null,alreadyAdded:!1,addedName:null,deviceId:null,needsParams:[],parentId:null}));i(s,n),(s.hit===null||n===`scan`)&&(s.hit=t),s.name=t.suggestedName,s.address=o??s.address,a!==null&&(s.proposalId=a),s.parentId=t.parentStableId??s.parentId,s.needsParams=t.needsParams??s.needsParams,(t.alreadyOnboarded===!0||t.onboardedDeviceId!==void 0||e.existingStableIds.has(t.stableId))&&(s.alreadyAdded=!0,s.addedName=t.onboardedName??s.addedName,s.deviceId=t.onboardedDeviceId??e.existingDeviceIds?.get(t.stableId)??s.deviceId)};for(let t of e.scan)a(t,`scan`,null);for(let t of e.proposals)a(t.candidate,`proposal`,t.id);for(let n of t){let t=[...n.ids].find(t=>e.existingStableIds.has(t));t!==void 0&&(n.alreadyAdded=!0,n.deviceId=n.deviceId??e.existingDeviceIds?.get(t)??null)}return t.map(e=>{let t=e.parentId===null?void 0:n.get(e.parentId);return{key:e.key,name:e.name,address:e.address,sources:e.sources,hit:e.hit,adoptionId:e.adoptionId,proposalId:e.proposalId,alreadyAdded:e.alreadyAdded,addedName:e.addedName,deviceId:e.deviceId,needsParams:e.needsParams,parentKey:t!==void 0&&t!==e?t.key:null}})}c();function xt(e){return e instanceof Error?e.message:String(e)}function St(e){return e.isSuccess?`answered`:e.isError?`failed`:`pending`}function Ct({addonId:e,integrationId:t,adoption:i,enabled:a=!0}){let s=l(),c=q({addonId:e},{enabled:a}).data??null,[u,d]=o({}),f=Be(),p=V({},{enabled:a}),m=ce({projection:`slim`},{enabled:a}),h=ve(),g=Se(),[_,v]=o(new Set),[y,b]=o(new Set),[x,S]=o(null),[C,w]=o(null),T=n(()=>{if(!a)return[];let t=(p.data?.proposals??[]).filter(t=>t.addonId===e&&!$(t.candidate)).map(e=>({id:e.id,candidate:e.candidate})),n=m.data??[];return bt({adoption:i,scan:(f.data?.candidates??[]).filter(e=>!$(e)),proposals:t,existingStableIds:new Set(n.map(e=>e.stableId)),existingDeviceIds:new Map(n.map(e=>[e.stableId,e.id]))})},[a,i,p.data,f.data,m.data,e]),E=r(()=>{S(null),f.mutate({addonId:e,params:u})},[f,e,u]),D=r(async(e,t)=>{v(t=>new Set(t).add(e)),S(null);try{await t(),b(t=>new Set(t).add(e)),s.invalidateQueries({queryKey:[[`deviceManager`]]}),s.invalidateQueries({queryKey:[[`integrations`]]})}catch(e){S(xt(e))}finally{v(t=>{let n=new Set(t);return n.delete(e),n})}},[s]),O=r(async(n,r)=>{let i=n.hit;if(i!==null){await D(n.key,async()=>{await h.mutateAsync({addonId:e,integrationId:t,candidate:{...i,prefilledConfig:{...i.prefilledConfig,...r}}}),w(null)});return}if(n.adoptionId!==null){let r=n.adoptionId;await D(n.key,async()=>{await g.mutateAsync({addonId:e,integrationId:t,childNativeIds:[r]})})}},[h,g,e,t,D]),k=r(e=>{if(e.needsParams.length>0&&e.hit!==null){S(null),w(e);return}O(e)},[O]);return{rows:T,scanParamsSchema:c,scanParams:u,setScanParams:d,scanning:f.isPending,scanFailed:f.isError,scanAnswered:f.data!==void 0,runScan:E,proposals:a?St(p):`answered`,devices:a?St(m):`answered`,busy:_,added:y,error:x,paramsFor:C,setParamsFor:w,pick:k,addRow:O}}c();var wt=500;function Tt(e){return e instanceof Error?e.message:String(e)}function Et(e,t){let n={};for(let t of e?.sections??[])for(let e of t.fields)`key`in e&&e.key&&`default`in e&&e.default!==void 0&&(n[e.key]=e.default);return{...n,...t}}function Dt({addonId:t,integrationId:a,onClose:o}){let{t:s}=Q(),c=xe({addonId:t,integrationId:a,page:1,pageSize:wt},{retry:!1}),l=Ct({addonId:t,integrationId:a,adoption:n(()=>(c.data?.candidates??[]).map(e=>({childNativeId:e.childNativeId,name:e.name,alreadyAdopted:e.alreadyAdopted,adoptedDeviceId:e.adoptedDeviceId,parentStableId:e.parentStableId})),[c.data])}),{rows:d,paramsFor:f,busy:p,added:m,error:h}=l,g=r(e=>{let t=new Map(d.map(e=>[e.key,e])),n=0,r=e;for(;r?.parentKey!=null&&n<8&&(r=t.get(r.parentKey),r!==void 0);)n+=1;return n},[d]);if(f!==null&&f.hit!==null)return i(Mt,{addonId:t,integrationId:a,row:f,found:f.hit.prefilledConfig,busy:p.has(f.key),error:h,embedded:!1,onBack:()=>l.setParamsFor(null),onSubmit:e=>void l.addRow(f,e)});let _=l.proposals===`answered`&&!l.scanning;return e(u,{children:[e(X,{className:`space-y-3`,children:[i(Ot,{scan:l,listed:d.length}),d.length===0&&_&&i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:l.scanAnswered?s(`integrations.addDeviceModal.nothingFound`,`No devices responded to the scan.`):s(`integrations.addDeviceModal.scanHint`,`Scan the network to find devices to add.`)}),i(`div`,{className:`space-y-1.5`,"data-testid":`network-candidates`,children:d.map(e=>i(jt,{row:e,depth:g(e),busy:p.has(e.key),added:m.has(e.key),devicesKnown:l.devices===`answered`,onPick:l.pick,onNavigate:o},e.key))})]}),i(je,{children:i(j,{variant:`outline`,size:`sm`,onClick:o,children:s(`integrations.close`,`Close`)})})]})}function Ot({scan:t,listed:n}){let{t:r}=Q(),[a,s]=o(!1),c=t.scanning?r(`integrations.addDeviceModal.scanning`,`Scanning the local network…`):n>0?r(`integrations.addDeviceModal.found`,{defaultValue_one:`{{count}} device found`,defaultValue_other:`{{count}} devices found`,count:n}):``;return e(`div`,{className:`shrink-0 space-y-2 pb-3`,"data-testid":`scan-controls`,children:[i(U,{expanded:a,onExpandedChange:s,header:e(u,{children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`text-sm font-medium text-foreground`,children:r(`integrations.addDeviceModal.scanSection`,`Network scan`)}),c!==``&&i(`p`,{className:`truncate text-xs text-foreground-subtle`,children:c})]}),i(`span`,{role:`presentation`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e(j,{variant:`outline`,size:`sm`,onClick:t.runScan,disabled:t.scanning,children:[t.scanning?i(C,{className:`h-3.5 w-3.5 animate-spin`}):i(E,{className:`h-3.5 w-3.5`}),r(`integrations.addDeviceModal.scanNow`,`Scan now`)]})})]}),children:e(`div`,{className:`space-y-3`,children:[i(Ze,{}),t.scanParamsSchema&&i(Ke,{schema:t.scanParamsSchema,values:t.scanParams,onChange:t.setScanParams})]})}),t.scanFailed&&i(kt,{text:r(`integrations.addDeviceModal.scanFailed`,`The scan failed. Try again.`)}),t.proposals===`failed`&&i(kt,{text:r(`integrations.addDeviceModal.proposalsFailed`,`The devices found in the background could not be read. Scan now to look again.`)}),t.devices===`failed`&&i(kt,{text:r(`integrations.addDeviceModal.devicesFailed`,`The hub's device list could not be read, so Add is unavailable. Reopen this window to try again.`)}),t.error!==null&&i(kt,{text:t.error})]})}function kt({text:t}){return e(`div`,{className:`flex items-start gap-2 rounded-lg border border-danger/40 bg-danger/10 px-3 py-2`,children:[i(v,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-danger`}),i(`p`,{className:`text-xs text-danger`,children:t})]})}function At({row:t,busy:n,devicesKnown:r,onPick:a}){let{t:o}=Q();if(t.hit?.selectable===!1)return null;let s=t.needsParams.length>0;return e(j,{size:`sm`,variant:s?`outline`:`primary`,onClick:()=>a(t),disabled:n||!r,children:[n?i(C,{className:`h-3.5 w-3.5 animate-spin`}):s?null:i(f,{className:`h-3.5 w-3.5`}),s?o(`integrations.addDeviceModal.enterDetails`,`Enter details`):o(`common.add`,`Add`)]})}function jt({row:t,depth:n,busy:r,added:a,devicesKnown:o,onPick:s,onNavigate:c}){let l=t.alreadyAdded||a;return e(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-surface px-3 py-2 ${n>0?`ml-4`:``}`,"data-testid":`network-row-${t.key}`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[i(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.name}),t.address!==null&&i(`p`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:t.address})]}),l?i(dt,{deviceId:t.deviceId,deviceName:t.addedName,onNavigate:c}):i(At,{row:t,busy:r,devicesKnown:o,onPick:s})]})}function Mt({addonId:t,integrationId:n,row:r,found:a,busy:s,error:c,onBack:l,onSubmit:d,embedded:f}){let{t:p}=Q(),m=K({addonId:t,integrationId:n}),h=m.data?.deviceType??null,g=z({addonId:t,integrationId:n,type:h??P.Camera},{enabled:m.isSuccess&&h!==null}),_=g.data??null,[v,y]=o(null),x=v??Et(_,a),S=m.error??g.error,w=m.isSuccess&&h===null,T=_!==null,E=T?i(Ke,{schema:_,values:x,onChange:y}):S?i(kt,{text:Tt(S)}):w?i(`p`,{className:`text-xs text-foreground-muted`,children:p(`integrations.addDeviceModal.noCreationType`,`This integration cannot create a device from this candidate.`)}):i(C,{className:`mx-auto h-5 w-5 animate-spin text-primary`}),D=e(u,{children:[e(j,{variant:`ghost`,size:`sm`,onClick:l,children:[i(b,{className:`h-3.5 w-3.5`}),p(`integrations.addDeviceModal.back`,`Back to the list`)]}),i(`p`,{className:`text-xs font-medium text-foreground`,children:r.name}),E,c!==null&&i(kt,{text:c})]}),O=e(u,{children:[i(j,{variant:`outline`,size:`sm`,onClick:l,children:p(`integrations.cancel`,`Cancel`)}),e(j,{variant:`primary`,size:`sm`,onClick:()=>d(x),disabled:s||!T,children:[s&&i(C,{className:`h-3.5 w-3.5 animate-spin`}),p(`common.add`,`Add`)]})]});return f?e(`div`,{className:`shrink-0 space-y-3 border-b border-border pb-3`,children:[D,i(`div`,{className:`flex justify-end gap-2`,children:O})]}):e(u,{children:[i(X,{className:`space-y-3`,children:D}),i(je,{children:O})]})}c();var Nt=`devices`;function Pt(e){return{id:Nt,label:e(`integrations.adoptDevicesModal.defaultFilter`),isDefault:!0}}var Ft=2e4,It=100;function Lt(e,t){if(e.kind===`found`)return{adopted:e.row.alreadyAdded||t.has(e.row.key),deviceId:e.row.deviceId};let{candidate:n,found:r}=e;return{adopted:n.alreadyAdopted||r!==null&&(r.alreadyAdded||t.has(r.key)),deviceId:n.adoptedDeviceId??r?.deviceId??null}}function Rt(e){return e.kind===`candidate`?e.candidate.childNativeId:e.row.key}function zt(e){return e.kind===`candidate`?gt(e.candidate):`${e.row.name} ${e.row.address??``}`.toLowerCase()}function Bt({addonId:s,integrationId:c,onClose:d,withScan:f=!1}){let h=m(),{t:g}=Q(),_=l(),[y,b]=o(new Set),[x,S]=o(new Set),[T,E]=o(new Map),[D,O]=o(null),{data:A}=oe(),M=(A??[]).find(e=>e.addonId===s)?.supportsLocationImport??!1,[N,ee]=o(!0),F=Me({addonId:s,integrationId:c}).data?.filters,I=F&&F.length>0?F:[Pt(g)],[L,te]=o(I.find(e=>e.isDefault)?.id??(I.some(e=>e.id===Nt)?Nt:I[0].id)),ne=L!==Nt,R=Pe(),z=xe({addonId:s,integrationId:c,page:1,pageSize:Ft,filter:L}),B=z.refetch,V=R.mutate,re=r(()=>{V({addonId:s,integrationId:c},{onSettled:()=>{B()}})},[V,s,c,B]),H=t(null);a(()=>{let e=`${s}::${c}`;H.current===e||z.isLoading||(H.current=e,(z.data?.candidates.length??0)===0&&re())},[s,c,z.isLoading,z.data,re]);let ie=R.isPending,ae=R.isError?R.error instanceof Error?R.error.message:String(R.error):null,se=typeof R.data?.lastError==`string`&&R.data.lastError.length>0?R.data.lastError:null,ce=z.data,U=n(()=>ce?.candidates??[],[ce]),W=n(()=>mt(U),[U]),G=Ct({addonId:s,integrationId:c,adoption:n(()=>U.map(e=>({childNativeId:e.childNativeId,name:e.name,alreadyAdopted:e.alreadyAdopted,adoptedDeviceId:e.adoptedDeviceId,parentStableId:e.parentStableId,mac:e.metadata.mac})),[U]),enabled:f}),ue=f&&L===Nt,de=n(()=>{let e=new Map(G.rows.flatMap(e=>e.adoptionId===null?[]:[[e.adoptionId,e]])),t=W.map(t=>({kind:`candidate`,candidate:t.candidate,found:ue?e.get(t.candidate.childNativeId)??null:null})),n=ue?G.rows.filter(e=>e.adoptionId===null).map(e=>({kind:`found`,row:e})):[];return[...t,...n]},[W,G.rows,ue]),fe=n(()=>new Map(W.map(e=>[e.candidate.childNativeId,e.depth])),[W]),me=n(()=>new Map(W.map(e=>[e.candidate.childNativeId,e.parentName])),[W]),K=z.isError?z.error instanceof Error?z.error.message:String(z.error):null,he=Se(),[q,ge]=o(null),J=r(e=>{e.alreadyAdopted||b(t=>{let n=new Set(t);return n.has(e.childNativeId)?n.delete(e.childNativeId):n.add(e.childNativeId),n})},[]),Y=r(e=>{S(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_e=r((e,t)=>{E(n=>{let r=new Map(n),i=r.get(e)?.hiddenChildIds??new Set,a=new Set(i);return a.has(t)?a.delete(t):a.add(t),a.size===0?r.delete(e):r.set(e,{hiddenChildIds:a}),r})},[]),ve=r(e=>{let t={};for(let n of e){let e=T.get(n);e&&e.hiddenChildIds.size>0&&(t[n]={hiddenChildIds:[...e.hiddenChildIds]})}return Object.keys(t).length>0?t:void 0},[T]),ye=r(async()=>{O(null);let e=[...y];if(e.length!==0)try{let t=ve(e),{jobId:n}=await he.mutateAsync({addonId:s,integrationId:c,filter:L,childNativeIds:e,...t?{perCandidate:t}:{},...M?{importLocations:N}:{}});ge(n),b(new Set),E(new Map)}catch(e){O(e instanceof Error?e.message:String(e))}},[y,ve,he,s,c,L,M,N]),be=t(null),X=r(()=>{q===null||be.current===q||(be.current=q,B(),_.invalidateQueries({queryKey:[[`integrations`]]}),_.invalidateQueries({queryKey:[[`deviceManager`]]}))},[q,B,_]),Ce=r(e=>{te(e),b(new Set),S(new Set),E(new Map),O(null)},[]),we=y.size,Z=q!==null&&we===0&&!he.isPending,Te=de.filter(e=>e.kind===`found`||e.found!==null&&e.found.hit!==null).length,Ee=(ae??K??se)&&U.length===0?``:ue?G.proposals!==`answered`||G.scanning?``:G.scanAnswered?g(`integrations.addDeviceModal.nothingFound`,`No devices responded to the scan.`):g(`integrations.addDeviceModal.scanHint`,`Scan the network to find devices to add.`):g(`integrations.adoptNoCandidates`,{defaultValue:`No candidate devices found.`});return G.paramsFor!==null&&G.paramsFor.hit!==null?i(Mt,{addonId:s,integrationId:c,row:G.paramsFor,found:G.paramsFor.hit.prefilledConfig,busy:G.busy.has(G.paramsFor.key),error:G.error,embedded:!1,onBack:()=>G.setParamsFor(null),onSubmit:e=>{G.paramsFor!==null&&G.addRow(G.paramsFor,e)}}):e(u,{children:[f&&i(Ot,{scan:G,listed:ue?Te:0}),M&&e(`label`,{className:`flex items-center gap-1.5 cursor-pointer text-[11px] text-foreground-subtle hover:text-foreground transition-colors`,children:[i(k,{checked:N,onChange:e=>ee(e.target.checked),className:`accent-primary`}),g(`integrations.importLocations`,{defaultValue:`Import locations from the integration`})]}),e(`div`,{className:`flex-1 min-h-0 flex flex-col gap-2 overflow-hidden`,children:[(ae??K??se)&&U.length===0&&i(`div`,{className:`rounded-lg border border-danger/30 bg-danger/5 px-4 py-3 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(v,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),e(`div`,{className:`min-w-0`,children:[i(`p`,{className:`text-xs font-medium text-danger`,children:g(`integrations.adoptRefreshFailed`,{defaultValue:`Could not discover devices.`})}),i(`p`,{className:`text-[11px] text-danger/90 mt-0.5`,children:ae??K??se})]})]})}),I.length>1&&i(Vt,{filters:I,activeFilter:L,onSelect:Ce}),i(`div`,{className:`flex-1 min-h-0`,children:i(ze,{mode:`generic`,items:de,pageSize:It,getKey:Rt,getSearchText:zt,getFilterType:e=>e.kind===`candidate`?e.candidate.type:e.row.hit?.type??null,filterOptions:pe(h),filterLabel:g(`integrations.adoptColType`,{defaultValue:`Type`}),isLoading:z.isLoading||ie&&U.length===0,searchPlaceholder:g(`integrations.adoptSearch`,{defaultValue:`Search candidates…`}),emptyLabel:Ee,toolbar:e(j,{variant:`unstyled`,type:`button`,onClick:re,disabled:ie,title:g(`integrations.adoptRefreshTitle`,{defaultValue:`Reload this integration's device list (does not scan the network)`}),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-60 shrink-0`,children:[i(w,{className:`h-3.5 w-3.5 ${ie?`animate-spin`:``}`}),g(`integrations.adoptRefresh`,{defaultValue:`Refresh`})]}),columns:[{key:`name`,header:g(`integrations.adoptColName`,{defaultValue:`Name`}),headerClassName:`w-full sm:w-[55%]`,cellClassName:`max-w-0`,cell:e=>{let t=Lt(e,G.added);if(e.kind===`found`)return i(Ut,{row:e.row,adopted:t.adopted,deviceId:t.deviceId,typeLabel:le(e.row.hit?.type??P.Camera,h).label,alignWithChevron:!ne,onNavigate:d});let n=e.candidate;return i(Ht,{candidate:n,depth:fe.get(n.childNativeId)??0,...me.get(n.childNativeId)===void 0?{}:{containerName:me.get(n.childNativeId)},expandable:!ne,expanded:x.has(n.childNativeId),onToggleExpand:()=>Y(n.childNativeId),adopted:t.adopted,deviceId:t.deviceId,onNavigate:d,typeLabel:le(n.type,h).label})}},{key:`type`,header:g(`integrations.adoptColType`,{defaultValue:`Type`}),headerClassName:`w-[30%] hidden sm:table-cell`,cellClassName:`hidden sm:table-cell`,cell:t=>{let n=le(t.kind===`candidate`?t.candidate.type:t.row.hit?.type??P.Camera,h),r=n.icon;return e(`span`,{className:`inline-flex items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(r,{className:`h-3.5 w-3.5 shrink-0`}),n.label]})}},{key:`select`,header:``,headerClassName:`w-10 sm:w-[15%] text-right`,cellClassName:`text-right`,cell:e=>{if(Lt(e,G.added).adopted)return null;let t=e.kind===`found`?e.row:e.found,n=t!==null&&t.hit!==null&&t.needsParams.length>0;if(t!==null&&(e.kind===`found`||n))return i(`div`,{className:`flex items-center justify-end`,children:i(At,{row:t,busy:G.busy.has(t.key),devicesKnown:G.devices===`answered`,onPick:G.pick})});if(e.kind!==`candidate`)return null;let r=e.candidate;return i(`div`,{className:`flex items-center justify-end`,children:i(j,{variant:`unstyled`,onClick:()=>J(r),"aria-label":y.has(r.childNativeId)?g(`integrations.adoptDevicesModal.deselect`,`Deselect`):g(`integrations.adoptDevicesModal.select`,`Select`),className:`inline-flex h-5 w-5 items-center justify-center rounded border ${y.has(r.childNativeId)?`border-primary bg-primary`:`border-border`}`,children:y.has(r.childNativeId)&&i(p,{className:`h-3 w-3 text-primary-foreground`})})})}}],isExpanded:e=>!ne&&e.kind===`candidate`&&x.has(e.candidate.childNativeId),renderExpanded:ne?void 0:e=>e.kind===`candidate`?i(Wt,{candidate:e.candidate,hiddenChildIds:T.get(e.candidate.childNativeId)?.hiddenChildIds??new Set,onToggleChildHidden:t=>_e(e.candidate.childNativeId,t)}):null,rowClassName:e=>Lt(e,G.added).adopted?`opacity-60`:e.kind===`candidate`&&y.has(e.candidate.childNativeId)?`bg-primary/5`:``})})]}),D&&i(`div`,{className:`border-t border-danger/30 bg-danger/5 px-3 py-2 shrink-0`,children:e(`div`,{className:`flex items-start gap-2`,children:[i(v,{className:`h-3.5 w-3.5 text-danger mt-0.5 shrink-0`}),i(`p`,{className:`text-[11px] text-danger`,children:D})]})}),q!==null&&i(pt,{addonId:s,integrationId:c,jobId:q,onFinished:X}),e(je,{children:[i(j,{variant:`outline`,size:`sm`,onClick:d,children:g(`integrations.cancel`,{defaultValue:`Cancel`})}),e(j,{variant:`primary`,size:`sm`,onClick:Z?d:ye,disabled:!Z&&(we===0||he.isPending),children:[he.isPending&&i(C,{className:`h-3.5 w-3.5 animate-spin`}),Z?g(`integrations.close`,{defaultValue:`Close`}):g(`integrations.addSelected`,{defaultValue:`Add selected`}),!Z&&we>0?` (${we})`:``]})]})]})}function Vt({filters:e,activeFilter:t,onSelect:n}){let{t:r}=Q();return i(`div`,{role:`tablist`,"aria-label":r(`integrations.adoptDevicesModal.discoveryGranularity`,`Discovery granularity`),className:`inline-flex shrink-0 self-start rounded-lg border border-border bg-surface p-0.5`,children:e.map(e=>{let r=e.id===t;return i(j,{variant:`unstyled`,type:`button`,role:`tab`,"aria-selected":r,onClick:()=>n(e.id),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${r?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:e.label},e.id)})})}function Ht({candidate:t,depth:n,containerName:r,expandable:a,expanded:o,onToggleExpand:s,adopted:c,deviceId:l,onNavigate:u,typeLabel:f}){let{t:p}=Q(),m=(t.children??[]).length,h=ht(t);return e(`div`,{className:`flex items-center gap-2.5 min-w-0 ${n>0?`pl-5`:``}`,children:[a&&m>0?e(j,{variant:`unstyled`,type:`button`,onClick:s,"aria-label":o?p(`integrations.adoptDevicesModal.collapse`,`Collapse`):p(`integrations.adoptDevicesModal.expand`,`Expand`),"aria-expanded":o,className:`flex h-5 flex-shrink-0 items-center justify-center gap-0.5 rounded px-0.5 text-[10px] text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:[i(o?F:d,{className:`h-3.5 w-3.5`}),m]}):a?i(`span`,{className:`h-5 w-5 flex-shrink-0`,"aria-hidden":`true`}):null,e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`truncate text-xs font-medium text-foreground`,"data-testid":`candidate-name`,children:t.name}),h.length>0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-subtitle`,children:h}),r!==void 0&&i(`div`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`candidate-container`,children:p(`integrations.adoptDevicesModal.inContainer`,`in {{name}}`,{name:r})}),i(`div`,{className:`truncate text-[10px] text-foreground-subtle sm:hidden`,children:f})]}),c&&i(dt,{deviceId:l,onNavigate:u})]})}function Ut({row:t,adopted:n,deviceId:r,typeLabel:a,onNavigate:o,alignWithChevron:s}){return e(`div`,{className:`flex items-center gap-2.5 min-w-0`,"data-testid":`network-row-${t.key}`,children:[s&&i(`span`,{className:`h-5 w-5 flex-shrink-0`,"aria-hidden":`true`}),e(`div`,{className:`min-w-0 flex-1`,children:[i(`div`,{className:`truncate text-xs font-medium text-foreground`,"data-testid":`candidate-name`,children:t.name}),t.address!==null&&i(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,children:t.address}),i(`div`,{className:`truncate text-[10px] text-foreground-subtle sm:hidden`,children:a})]}),n&&i(dt,{deviceId:r,deviceName:t.addedName,onNavigate:o})]})}function Wt({candidate:t,hiddenChildIds:n,onToggleChildHidden:r}){let{t:a}=Q(),o=t.children??[];return o.length===0?null:i(`div`,{className:`space-y-1 py-1`,children:o.map(t=>{let o=n.has(t.childNativeId),s=t.capabilities??[];return e(`div`,{className:`flex items-center gap-2 rounded px-2 py-1 ${o?`opacity-50`:``}`,children:[i(`span`,{className:`text-[11px] text-foreground truncate flex-1 min-w-0`,children:t.name}),s.length>0&&i(`span`,{className:`text-[9px] text-foreground-subtle truncate`,children:s.join(`, `)}),i(j,{variant:`unstyled`,onClick:()=>r(t.childNativeId),"aria-label":o?a(`integrations.adoptDevicesModal.showChild`,`Show child`):a(`integrations.adoptDevicesModal.hideChild`,`Hide child`),title:o?a(`integrations.adoptDevicesModal.showAfterAdopt`,`Show after adopt`):a(`integrations.adoptDevicesModal.hideAfterAdopt`,`Hide after adopt`),className:`flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors flex-shrink-0`,children:i(o?M:h,{className:`h-3 w-3`})})]},t.childNativeId)})})}c();var Gt=`flex min-h-0 flex-1 flex-col`;function Kt(e){return e===`manual`?`manual`:e===`pairing`?`pairing`:`network`}function qt({reason:e}){let{t}=Q();return i(X,{children:i(J,{message:t(`integrations.addDeviceModal.scanUnavailable`,{defaultValue:`The network scan is unavailable for this integration: {{reason}}`,reason:e})})})}function Jt({addonId:t,integrationId:n,kind:r,canScan:a,scanFailure:s=null,onClose:c,pairing:l}){let{t:d}=Q(),f=lt(t,n),p=r===`device-adoption`&&a===null,m=r===`device-adoption`||a===!0||s!==null,h=f===`available`,[g,_]=o(null),v=g??(l===void 0?m?`network`:`manual`:`pairing`),y=[m,h,l!==void 0].filter(Boolean).length,b=p?i(X,{children:i(C,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):r===`device-adoption`?e(u,{children:[s!==null&&i(qt,{reason:s}),i(Bt,{addonId:t,integrationId:n,onClose:c,withScan:a===!0})]}):s===null?i(Dt,{addonId:t,integrationId:n,onClose:c}):i(qt,{reason:s}),x=i(ut,{integrationId:n,addonId:t,onClose:c});return i(te,{open:!0,onOpenChange:e=>{e||c()},children:e(Ne,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,className:r===`device-adoption`?`md:h-[85vh]`:void 0,children:[i(De,{children:i(_e,{children:d(`integrations.addDevice`,`Add device`)})}),y>1?e(Te,{value:v,onValueChange:e=>_(Kt(e)),className:Gt,children:[e(Y,{className:`shrink-0`,children:[m&&i(Ie,{value:`network`,children:l?.networkLabel??d(`integrations.addDeviceModal.tabNetwork`,`Found on the network`)}),h&&i(Ie,{value:`manual`,children:d(`integrations.addDeviceModal.tabManual`,`Enter parameters`)}),l!==void 0&&i(Ie,{value:`pairing`,children:l.label})]}),m&&i(we,{value:`network`,className:Gt,children:b}),h&&i(we,{value:`manual`,className:Gt,children:x}),l!==void 0&&i(`div`,{role:`tabpanel`,id:`tabpanel-pairing`,hidden:v!==`pairing`,className:`pt-3`,children:l.render({onPaired:()=>_(`network`)})})]}):l!==void 0&&!m&&!h?l.render({onPaired:()=>_(`network`)}):m?b:h?x:f===`loading`?i(X,{children:i(C,{className:`mx-auto h-5 w-5 animate-spin text-primary`})}):i(X,{children:i(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:d(`integrations.addDeviceModal.nothingToAdd`,`This integration has no way to add a device from here.`)})})]})})}c();var Yt=`matter`,Xt=`matter-broker`,Zt=[`discovering`,`pase`,`commissioning`,`done`];function Qt(e){return!(typeof e!=`object`||!e||!(`phase`in e)||typeof e.phase!=`string`)}function $t(e,t){return e===`code-expired`||t?.includes(`matter-commission:code-expired`)?{key:`integrations.addMatter.failure.expired`,defaultValue:`The pairing code expired. Share the device again and paste the new code.`}:e===`device-not-found`||t?.includes(`matter-commission:device-not-found`)?{key:`integrations.addMatter.failure.notFound`,defaultValue:`No Matter device with that code was found on the network.`}:e===`wrong-code`||t?.includes(`matter-commission:wrong-code`)?{key:`integrations.addMatter.failure.wrongCode`,defaultValue:`The pairing code was rejected.`}:e===`invalid-code`||t?.includes(`invalid pairing code`)?{key:`integrations.addMatter.failure.invalid`,defaultValue:`Enter an 11-digit or 21-digit manual code, or a code that starts with MT:.`}:{key:`integrations.addMatter.failure.unknown`,defaultValue:t??`Commissioning failed.`}}function en({brokerId:t,onClose:n,onCommissioned:r}){let{t:s}=Q(),c=Ee({kind:Yt}).data?.find(e=>e.id===t)??null,l=c!==null&&!c.usable,d=Re(),[f,p]=o(``),[m,h]=o({phase:`idle`,failure:null,message:null}),g=m.phase===`discovering`||m.phase===`pase`||m.phase===`commissioning`,_=be({addonId:Xt,brokerId:t??``,key:`commission`},{enabled:t!==null&&g,refetchInterval:g?400:!1});a(()=>{g&&Qt(_.data)&&_.data.phase!==`idle`&&h({phase:_.data.phase,failure:typeof _.data.failure==`string`?_.data.failure:null,message:typeof _.data.message==`string`?_.data.message:null})},[g,_.data]);let v=()=>{t!==null&&(h({phase:`discovering`,failure:null,message:null}),d.mutate({addonId:Xt,brokerId:t,target:{action:`commissionNode`},payload:{pairingCode:f.trim()}},{onSuccess:()=>h({phase:`done`,failure:null,message:null}),onError:e=>{let t=e instanceof Error?e.message:`Commissioning failed.`;h({phase:`failed`,failure:t.includes(`matter-commission:`)?t.split(`matter-commission:`)[1]?.split(`:`)[0]??`unknown`:t.includes(`invalid pairing code`)?`invalid-code`:`unknown`,message:t})}}))},y=m.phase===`failed`?$t(m.failure,m.message):null,b=y===null?null:s(y.key,{defaultValue:y.defaultValue}),x=t===null;return e(u,{children:[e(X,{className:`space-y-4`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`integrations.addMatter.help`,{defaultValue:`Paste the 11-digit pairing code or the MT: QR code.`})}),x&&i(J,{message:s(`integrations.addMatter.noFabric`,{defaultValue:`This integration is not linked to a Matter fabric. Edit it to link one.`})}),c!==null&&l&&i(J,{message:s(`integrations.addMatter.fabricDown`,{defaultValue:`The Matter fabric is not running ({{state}}). It starts again with the Matter addon; try again in a moment.`,state:c.stateLabel??c.state})}),!x&&e(`div`,{className:`space-y-1.5`,children:[i(B,{htmlFor:`matter-pairing-code`,children:s(`integrations.addMatter.code`,{defaultValue:`Pairing code`})}),i(A,{id:`matter-pairing-code`,value:f,autoComplete:`off`,spellCheck:!1,placeholder:`34970112332`,disabled:g||m.phase===`done`,onChange:e=>p(e.target.value)})]}),m.phase!==`idle`&&i(`ol`,{className:`space-y-1`,"aria-label":s(`integrations.addMatter.progress`,{defaultValue:`Commissioning progress`}),children:Zt.map(t=>{let n=m.phase===t;return e(`li`,{className:`text-xs ${n?`text-foreground font-medium`:`text-foreground-subtle`}`,children:[n&&g?i(C,{className:`mr-1 inline h-3 w-3 animate-spin`}):null,s(`integrations.addMatter.phase.${t}`,{defaultValue:t===`discovering`?`Discovering`:t===`pase`?`PASE`:t===`commissioning`?`Commissioning`:`Done`})]},t)})}),b!==null&&i(J,{message:b})]}),e(je,{children:[i(j,{variant:`ghost`,size:`sm`,onClick:n,children:s(`common.close`,{defaultValue:`Close`})}),m.phase===`done`?i(j,{size:`sm`,onClick:r,children:s(`integrations.adoptDevices`,{defaultValue:`Adopt devices`})}):i(j,{size:`sm`,disabled:g||x||c===null||l||f.trim().length===0,onClick:v,children:g?s(`integrations.addMatter.working`,{defaultValue:`Adding…`}):s(`integrations.addMatter.submit`,{defaultValue:`Add device`})})]})]})}function tn({addonId:t,integrationId:n,name:r,onClose:a,onSaved:o}){let{t:c}=Q(),l=N(),u=s({queryKey:[`integration-instance-describe`,t],queryFn:()=>l.trpcClient.integrationInstances.describe.query({addonId:t})}),d=s({queryKey:[`integration-instance`,t,n],queryFn:()=>l.trpcClient.integrationInstances.getInstance.query({addonId:t,id:n})});if(u.isSuccess&&d.isSuccess&&d.data!==null)return i(Je,{addonId:t,providerName:r,description:u.data,instance:d.data,onClose:a,onSaved:()=>o()});let f=u.isError||d.isError||d.isSuccess&&!d.data;return i(te,{open:!0,onOpenChange:e=>!e&&a(),children:e(Ne,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(De,{children:e(_e,{children:[c(`integrations.editConfig`,{defaultValue:`Edit configuration`}),` — `,r]})}),i(X,{children:f?i(`p`,{className:`text-[11px] text-danger`,children:c(`integrations.loadFailed`,{defaultValue:`Could not load this integration.`})}):e(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[i(C,{className:`h-3 w-3 animate-spin`}),c(`integrations.loading`,{defaultValue:`Loading…`})]})})]})})}c();function nn(){let{addonId:e=``}=He();return i(an,{addonId:e})}function rn(){return e(`div`,{className:`p-4`,children:[i(`div`,{className:`h-16 rounded-lg bg-surface animate-pulse mb-4`}),i(`div`,{className:`h-40 rounded-lg bg-surface animate-pulse`})]})}function an({addonId:t}){let{t:c}=Q(),u=l(),d=Ue(),[f,p]=Ge(),m=N(),[h,g]=o(!1),[_,v]=o(!1),[y,w]=o(!1),{data:E}=Ae(void 0),k=n(()=>(E??[]).filter(e=>e.addonId===t),[E,t]),A=$e(f.get(Ye),k)??``,M=r(e=>{p(t=>{let n=new URLSearchParams(t);return n.set(Ye,e),n},{replace:!0})},[p]),P=n(()=>k.map(e=>({value:e.id,label:e.name})),[k]),{data:F,isLoading:L}=re({id:A},{enabled:!!A}),{data:z,isSuccess:B}=oe(),V=n(()=>{let e=F?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.kind===`device-adoption`?`device-adoption`:`device-provider`},[z,F?.addonId,B]),{data:le,isPending:U}=ye({}),{data:pe,isPending:K}=H({capName:`integration-instances`}),q=(pe??[]).some(e=>e.addonId===t),J=de({addonId:t},{retry:!1,enabled:q}),Y=Ve({addonId:t,id:A},{retry:!1,enabled:q&&A!==``}),{canScan:ve,scanFailure:be}=n(()=>{if(U||K||q&&(J.isPending||Y.isPending))return{canScan:null,scanFailure:null};if(!(le?.providers??[]).some(e=>e.addonId===F?.addonId))return{canScan:!1,scanFailure:null};if(!q)return{canScan:!0,scanFailure:null};let e=J.isError?J.error:Y.isError?Y.error:null;if(J.isError||Y.isError){let t=e instanceof Error?e.message:``;return{canScan:!1,scanFailure:t.length>0?t:`unknown error`}}return{canScan:(Y.data?.addDevice??(J.data===void 0?`none`:ee(J.data)))===`scan`,scanFailure:null}},[U,K,q,J.isPending,J.isError,J.error,J.data,Y.isPending,Y.isError,Y.error,Y.data,le,F?.addonId]),xe=V!==null,Se=F?.info?.fixed===!0,we=n(()=>{let e=F?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.brokerKind??null},[z,F?.addonId,B])===`matter`,Z=Y.data?.formValues?.brokerId,Te=typeof Z==`string`&&Z!==``?Z:null,Ee=xe?c(`integrations.addDevice`,`Add device`):c(`integrations.addDeviceLoading`,{defaultValue:`Loading…`}),Oe=n(()=>{let e=F?.addonId;return!e||!B?null:(z??[]).find(t=>t.addonId===e)?.mode??null},[z,F?.addonId,B]);a(()=>{f.get(`add`)===`1`&&xe&&(g(!0),p(e=>{let t=new URLSearchParams(e);return t.delete(`add`),t},{replace:!0}))},[f,xe,p]);let{data:ke}=s({queryKey:[`integration-instance-form`,F?.addonId,F?.id],enabled:!!F?.addonId&&!!F?.id,queryFn:()=>m.trpcClient.integrationInstances.instanceFormSchema.query({addonId:F?.addonId??``,id:F?.id??``})}),je=ke!=null&&Array.isArray(ke.sections)&&ke.sections.some(e=>e.fields.length>0),{data:Me}=ce({projection:`slim`},{refetchInterval:3e4}),Pe=[[`integrations`,`get`],{input:{id:A},type:`query`}],Fe=ie({onMutate:async e=>{await u.cancelQueries({queryKey:Pe});let t=u.getQueryData(Pe);return t!=null&&u.setQueryData(Pe,{...t,enabled:e.enabled}),{previous:t}},onError:(e,t,n)=>{let r=n;r?.previous!=null&&u.setQueryData(Pe,r.previous)},onSettled:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ie={isPending:Fe.isPending,mutate:e=>Fe.mutate({id:e.id,enabled:e.enabled})},Re={onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]}),d(k.length>1?et(t):`/integrations`)}},Be=se(Re),He=ge(Re),We=F?.processState===`running`,Ke={isPending:Be.isPending||He.isPending,mutateAsync:async e=>{We?await Be.mutateAsync(e):await He.mutateAsync({id:e.id})}},qe=he({onSuccess:()=>{u.invalidateQueries({queryKey:[[`integrations`]]}),u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Je=tt(),Xe=Ce({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ze=ne({onSuccess:()=>{u.invalidateQueries({queryKey:[[`deviceManager`]]})}}),$=n(()=>Me??[],[Me]),Qe=n(()=>G($),[$]),rt=r(e=>Qe.get(e)??null,[Qe]),it=n(()=>fe(E),[E]),at=r(e=>d(`/devices/${String(e)}`),[d]),ot=n(()=>$.filter(e=>{let t=it(e);return t.kind===`resolved`&&t.integration.id===A}),[$,A,it]),st=n(()=>E===void 0?null:me(ot).length,[E,ot])??`…`;if(L||E===void 0)return i(rn,{});let ct=(z??[]).find(e=>e.addonId===t)?.name??F?.name??t;return F?e(`div`,{className:`flex h-full min-h-0 flex-col gap-4 overflow-x-hidden p-4`,children:[i(ue,{items:[{label:c(`integrationDetail.integrations`,`Integrations`),onClick:()=>d(`/integrations`)},{label:ct}]}),e(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[e(`div`,{className:`flex items-center gap-3 min-w-0`,children:[i(on,{addonId:F.addonId}),e(`div`,{className:`min-w-0`,children:[i(`h1`,{className:`text-lg font-semibold text-foreground truncate`,children:ct}),e(`p`,{className:`text-[11px] text-foreground-subtle mt-0.5 truncate`,children:[st,` `,c(`integrations.devices`)]})]})]}),e(`div`,{className:`flex flex-nowrap items-center justify-end gap-2`,children:[!Se&&e(j,{variant:`unstyled`,onClick:()=>{g(!0)},disabled:!xe,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50 disabled:cursor-not-allowed`,title:Ee,children:[i(D,{className:`h-3.5 w-3.5`}),Ee]}),i(`div`,{className:`flex flex-col items-end gap-1`,children:e(`div`,{className:`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 transition-colors ${Ie.isPending?`opacity-60`:``} ${F.enabled?`border-success/30 bg-success/5`:`border-border bg-surface`}`,title:c(`integrations.toggleHint`,{defaultValue:`Click to toggle`}),children:[i(R,{checked:F.enabled,onCheckedChange:e=>Ie.mutate({id:A,enabled:e}),disabled:Ie.isPending,"aria-label":F.enabled?c(`integrationDetail.disableIntegration`,`Disable integration`):c(`integrationDetail.enableIntegration`,`Enable integration`)}),i(`span`,{className:`text-[11px] font-medium ${F.enabled?`text-success`:`text-foreground-subtle`}`,children:F.enabled?c(`integrationDetail.enabled`,`Enabled`):c(`integrationDetail.disabled`,`Disabled`)}),Ie.isPending&&i(C,{className:`h-3 w-3 animate-spin text-foreground-subtle`})]})}),i(W,{moreLabel:c(`integrationDetail.more`,`More`),actions:[{id:`config`,label:c(`integrations.config`),icon:S,hidden:!(Oe!==`standalone`&&(je||V===`device-adoption`)),onClick:()=>v(!0)},{id:`logs`,label:c(`integrations.logs`,{defaultValue:`Logs`}),icon:T,title:c(`integrations.logs`,{defaultValue:`View logs`}),onClick:()=>w(!0)},{id:`restart`,label:c(`integrationDetail.restart`,`Restart`),icon:x,disabled:qe.isPending,confirm:{title:c(`integrationDetail.restart2`,`Restart "{{name}}"?`,{name:F.name}),description:c(`integrationDetail.restartingTheAddonWillBriefly`,`Restarting the addon will briefly disconnect every device backed by it ({{topLevelCountLabel}} active). Streams will reconnect automatically.`,{topLevelCountLabel:st}),action:()=>qe.mutateAsync({addonId:F.addonId})}},{id:`delete`,label:c(`integrations.delete`,{defaultValue:`Delete`}),icon:O,danger:!0,hidden:Se||!A,disabled:Ke.isPending,confirm:{title:c(`integrations.deleteTitle`,{defaultValue:`Delete integration?`}),description:c(`integrations.deleteWarning`,{defaultValue:`This removes the integration "{{name}}" and its {{count}} device(s). The addon will restart. This cannot be undone.`,name:F.name,count:st}),confirmLabel:c(`integrations.confirmDelete`,{defaultValue:`Delete integration`}),action:async()=>{A&&await Ke.mutateAsync({addonId:t,id:A})}}}]})]})]}),k.length>1&&i(`div`,{className:`max-w-sm`,children:i(ae,{mode:`single`,singleDisplay:`field`,label:c(`integrationDetail.instances`,`Integration`),options:P,value:A,onChange:M,testId:`integration-instance-picker`,optionTestIdPrefix:`integration-instance`})}),i(`div`,{className:`min-h-0 flex-1`,children:i(ze,{context:`integration-detail`,devices:$,trpc:m.trpcClient,integrationOf:it,forceIntegrationId:A,urlScope:`root`,lsKey:`integration-detail:${F.addonId}`,resolveIntegrationIcon:nt,resolveParent:rt,onNavigate:at,rowOperation:Je.rowOperation,batchActions:{remove:Je.remove,disable:Xe.mutate,enable:Ze.mutate},...Se?{}:{onDeleteDevice:e=>Je.remove({deviceId:e.id})}})}),h&&A&&V!==null&&i(Jt,{addonId:F.addonId,integrationId:A,kind:V,canScan:ve,scanFailure:be,...we?{pairing:{label:c(`integrations.addMatter.tab`,`Pairing code`),networkLabel:c(`integrations.addMatter.tabNetwork`,`Paired nodes`),render:({onPaired:e})=>i(en,{brokerId:Te,onClose:()=>g(!1),onCommissioned:e})}}:{},onClose:()=>g(!1)}),_&&A&&i(tn,{addonId:F.addonId,integrationId:A,name:F.name,onClose:()=>v(!1),onSaved:()=>{u.invalidateQueries()}}),y&&i(te,{open:!0,onOpenChange:e=>!e&&w(!1),children:e(Ne,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-5xl md:h-[80vh]`,children:[i(De,{className:`mb-0`,children:e(_e,{className:`flex items-center gap-2 min-w-0`,children:[i(T,{className:`h-4 w-4 text-primary shrink-0`}),i(`span`,{className:`truncate`,children:F.name}),e(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate font-normal`,children:[F.addonId,A?` · ${A}`:``]})]})}),i(X,{className:`min-h-0 overflow-hidden p-0`,children:i(Le,{addonId:F.addonId,limit:200,maxHeight:`max-h-full`,showScope:!1,className:`h-full border-0 rounded-none`})})]})})]}):e(`div`,{className:`flex flex-col items-center justify-center py-20 px-6 text-center gap-4`,children:[i(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-foreground-subtle/10`,children:i(I,{className:`h-6 w-6 text-foreground-subtle`})}),e(`div`,{className:`space-y-1 max-w-sm`,children:[i(`h2`,{className:`text-sm font-semibold text-foreground`,children:c(`integrations.integrationNotFound`,{defaultValue:`Integration not found`})}),i(`p`,{className:`text-[11px] text-foreground-subtle`,children:c(`integrations.integrationNotFoundHint`,{defaultValue:`The integration "{{id}}" does not exist. It may have been deleted, or the URL may be wrong.`,id:t})})]}),e(j,{variant:`unstyled`,onClick:()=>d(`/integrations`),className:`inline-flex items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-1.5 text-[11px] font-medium text-foreground hover:bg-surface-hover transition-colors`,children:[i(b,{className:`h-3 w-3`}),c(`integrations.backToList`,{defaultValue:`Back to integrations`})]})]})}function on({addonId:e}){let t=Xe(e),[n,r]=o(!1);return!t||n?null:i(`img`,{src:t,alt:``,className:`h-8 w-8 rounded-lg shrink-0`,onError:()=>r(!0)})}export{nn as IntegrationDetailPage};
|